Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T16:45:16.587Z
Answers.LastActivityDate: 2019-03-19T16:45:16.587Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <plugin-craftcommerce><plugin-craftcommerce2>
Title: How to display the featured image on a Commerce product:
ThreadText: # 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:
  
  ```twig
  <figure>
      <a href="{{ entry.url }}">
          <img src="{{ entry.featuredImage[0].getUrl('medium') }}" alt="">
      </a>
  </figure>
  
  ```
  
  **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.
  
  ```TWIG
  {% set asset = entry.featuredImage.one() %}
  {% if asset is not null %}
      <figure>
          <a href="{{ entry.url }}">
              <img src="{{ asset.getUrl('medium') }}" alt="">
          </a>
      </figure>
  {% endif %}
  
  ```
  
  
  ---
  
  