I have an entry with an asset field that has up to 3 assets in it. If I want to load just the second asset in my template code, what's the syntax for this? (can't find any references/examples)
Image assets are returned in an array. Let's say you have an assets field with the handle of images
. You can just use bracket notation to get the second item in the array using: entry.images[1]
. So if you wanted to return the URL you could just do:
{{ entry.images[1].url }}
In Craft 3 this should be:
{% if entry.images | length > 1 %}
{% set secondImage = entry.images.1 %}
{% endif %}