0

I discovered that I can replace:

{% for asset in entry.assetFieldHandle %}
    {{ asset.url }} -- {{ asset.width }} -- {{ asset.height }}
{% endfor %}

From assetFieldHandle to the name of the handle ... then it works. But why not with entry.assetFieldHandle?

{% for asset in entry.image %}
    {{ asset.url }} -- {{ asset.width }} -- {{ asset.height }}
{% endfor %}
2

I assume you got Entry.assetFieldHandle from the docs? That's a way of telling you that you should call the asset field you're looking for by its handle.

You'd have to use the actual asset field handle of the asset field you're addressing, because an entry could have multiple asset fields (so there is NO attribute assetFieldHandle within the entry).

Let's say that your entry has two asset fields: images (multiple images) and logo (1 image). In this case, this would be the way to display those assets:

{# get multiple assets from field with handle 'images' #}
{% for image in entry.images %}
    {{ image.link }}
{% endfor %}

{# if you know an asset field only contains 1 asset (because its input is limited to 1)
   you can use 'first()' to get it without any for loop #}
{{ entry.logo.first().link }}
1
  • Hi, thanks, I should have figured it out.
    – Csaba Dobo
    Nov 26 '14 at 8:37

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.