Exclude page.media.images|first

Is it possible to read all images execpt the first one? We need this at the blog page. First Image should be the header image and all other images should be a gallery.

Maybe there is a ready to use solution, but couldn’t find it…

I think you could just set a variable to be equal to page.media.images|first, and then you pull in the images for your gallery have a statement to the effect of, “for images in… If not equal to … Print image” I’m on mobile so can’t mock up the actual code

I tried something like this - but not working…

{% for image in page.media.images %}
{% if not page.media.images|first %}
{{ image.html }}
{% endif %}
{% endfor %}

The logic of {% if not page.media.images|first %} is just going to check if there is nothing in page.media.images.

In the for you can check the index of the loop, see http://twig.sensiolabs.org/doc/2.x/tags/for.html#the-loop-variable

:slight_smile: yeah

Found a solution…

        {% for image in page.media.images %}
            {% if image == page.media.images|first %} 
                <!-- do nothing, ignore that image -->
            {% else %}
                <a href="{{ image.url }}" data-lightbox="gallery-item">{{ image.html }}</a>					
            {% endif %}
        {% endfor %}

Come and see it in action: https://www.giesinger-ender.at/test-mit-fotos