I'm confused about how to use an uploaded asset in a template (or rather why it isn't working).

1) I create an asset source and folder (Note: I did not add any fields).

2) I added this as a field in my entry fields called heroImage

3) I uploaded an asset to my single entry for the page.

4) I added this to the template

{% for asset in entry.heroImage %}
             {{ asset.url() }}
{% endfor %}

5) I also tried

    {% set assets = entry.heroImage %}
    {% if assets | length %}
      <h3>Some great assets</h3>
      {% for asset in assets %}
          {{ asset.url }}
      {% endfor %}

    {% endif %}

I can see the image on the entry page but the template wont render it.

What could be

  • Does the template generate anything on the front end for #4? Mar 20 '15 at 4:25
  • This was my mistake the issue was i was doing something else to change entry on the previous line... {% set entry = entry.otherThing.first() %} Rookie...Can this be deleted?
    – Tim
    Mar 20 '15 at 14:26

Unless I'm misunderstanding the question, surely you'll need to use an IMG tag?

{% for asset in assets %}
    <img src="{{ asset.getUrl }}" />
{% endfor %}

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.