I created a field which uploads an image, and I want it to display it for each of my entries inside my for loop.

What's the code I should use to do it?

  • Is the image a field used only with one entry? Or is it a different image added to each of the entries in your loop? Jul 19, 2018 at 14:18

1 Answer 1

{% for element in elements %}
    {% set asset = element.assetFieldHandle.one() %}
    {% if asset is not null %}
        <img src="{{ asset.getUrl()">
    {% endif %}
{% endfor %}

Take a look at ElementQueries and how to handle errors


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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