<p><em>(Hopefully it is okay for me to answer my own question)</em></p>

<p>In the <strong>ElementType</strong> file, the <strong>getSources</strong> method needs to have the <em>hasThumbs</em> key set, as follows:</p>

<pre><code>public function getSources($context = null)
{
    $sources = array(
        '*' =&gt; array(
            'label'    =&gt; Craft::t('All assets'),
            'hasThumbs' =&gt; true,
        )
    );
}
</code></pre>

<p>In your <strong>Model</strong> file you have to have a <strong>getThumbUrl</strong> method defined, as follows:</p>

<pre><code>public function getThumbUrl()
{
    return $this-&gt;thumbnailUrl;
}
</code></pre>

<p>This results in a small thumbnail next to the title of your element, as seen in the screenshot:</p>

<p><a href="https://i.sstatic.net/ojalP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ojalP.png" alt="enter image description here"></a></p>

<p><a href="https://docs.craftcms.com/api/v2/elementtypes/BaseElementType.html" rel="nofollow noreferrer">The Craft 2 Class Reference</a> helped put this together for me.</p>

CC BY-SA 4.0
2018-06-12T15:18:04.130Z
2018-06-12T15:18:04.130Z
Will Diaz
<p>I'm trying to emulate what Assets does, in which a thumbnail of the asset is shown along side the title of the asset. When I alter the _toString() method of the model, what I get is the URL instead of the image (the URL is being added to the data-label attribute of the containing div).</p>

<p>Is there a way to accomplish what I'm after?</p>

<p><a href="https://i.sstatic.net/jtTx7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jtTx7.png" alt="The Element Type&#39;s title is displayed, but no image"></a></p>

<plugin-development><elementtype>
Is it possible to include a thumbnail in an element type index view?
# Is it possible to include a thumbnail in an element type index view?

(Asked by: username_0 on 2018-06-11)

I'm trying to emulate what Assets does, in which a thumbnail of the asset is shown along side the title of the asset. When I alter the \_toString() method of the model, what I get is the URL instead of the image (the URL is being added to the data-label attribute of the containing div).

Is there a way to accomplish what I'm after?

[![The Element Type's title is displayed, but no image](https://i.sstatic.net/jtTx7.png)](https://i.sstatic.net/jtTx7.png)

**Tags:** plugin-development, elementtype


---

## 1 answers

### Answer by username_0 on 2018-06-12. Score: 1

(Hopefully it is okay for me to answer my own question)
In the ElementType file, the getSources method needs to have the hasThumbs key set, as follows:
public function getSources($context = null)
{
    $sources = array(
        '*' => array(
            'label'    => Craft::t('All assets'),
            'hasThumbs' => true,
        )
    );
}

In your Model file you have to have a getThumbUrl method defined, as follows:
public function getThumbUrl()
{
    return $this->thumbnailUrl;
}

This results in a small thumbnail next to the title of your element, as seen in the screenshot:

The Craft 2 Class Reference helped put this together for me.


---

