<p>A good approach is always to check if the element even has a related asset or not, otherwhise you'll receive exceptions.</p>

<pre class="lang-TWIG prettyprint-override"><code>{% set asset = entry.featuredImage.one() %}
{% if asset is not null %}
    &lt;figure&gt;
        &lt;a href="{{ entry.url }}"&gt;
            &lt;img src="{{ asset.getUrl('medium') }}" alt=""&gt;
        &lt;/a&gt;
    &lt;/figure&gt;
{% endif %}
</code></pre>

CC BY-SA 4.0
2019-03-19T16:45:16.587Z
2019-03-19T16:45:16.587Z
Robin Schambach
<p>How do I display the featured image on a Commerce product:  </p>

<pre class="lang-twig prettyprint-override"><code>&lt;figure&gt;
    &lt;a href="{{ entry.url }}"&gt;
        &lt;img src="{{ entry.featuredImage[0].getUrl('medium') }}" alt=""&gt;
    &lt;/a&gt;
&lt;/figure&gt;
</code></pre>

<plugin-craftcommerce><plugin-craftcommerce2>
How to display the featured image on a Commerce product:
# How to display the featured image on a Commerce product:

(Asked by: username_0 on 2019-03-19)

How do I display the featured image on a Commerce product:

**Tags:** plugin-craftcommerce, plugin-craftcommerce2


---

## 1 answers

### Answer by username_1 on 2019-03-19. Score: 1 | Accepted answer

A good approach is always to check if the element even has a related asset or not, otherwhise you'll receive exceptions.
{% set asset = entry.featuredImage.one() %}
{% if asset is not null %}
    
        
            
        
    
{% endif %}


---

