Hi guys,
I have a template, where I would like to make a function that shows the first image associated with a page if it exists. I have looked into the documentation and figured out that I can use this:
{% set first_image = page.media.images|first %} to get that image.
However, it doesn’t work. I doesn’t show anything. So wondered if there wasn’t any image associated, so I ran this loop:
{% for image in page.media.images %}
{{ image.html }}
{% endfor %}
Which showed both of the images associated with the page.
Do any of you have an idea, why the first function I tried doesn’t work, as I should according to the documentation? And what suggestions do you have to make it work instead?
Thanks in advance.
Jonas