1

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

<figure>
    <a href="{{ entry.url }}">
        <img src="{{ entry.featuredImage[0].getUrl('medium') }}" alt="">
    </a>
</figure>
1

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 %}
    <figure>
        <a href="{{ entry.url }}">
            <img src="{{ asset.getUrl('medium') }}" alt="">
        </a>
    </figure>
{% endif %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.