Pulling two random images from folder

I hope my question isn’t to trivial…
how to accomplish the following:

I want to pull several random images from a folder but would like to prevent doubles.

Im using this bit of code:

{% set image = page.media.all|randomize|first %}
{% if image %}
{{ image.cropResize(400,400).html(’’,’’,‘align-’~page.header.image_align) }}
{% endif %}

I use it twice, two images are pulled… but allthough random, also double.
Is there a simple way for this? something like after randomize pull the |first&last from the generated aray? (if its an array being created that is)

You almost got it!
This should work

{% set image = page.media.all|randomize %}
{% if image|first %}
{{ image|first.cropResize(400,400).html(’’,’’,‘align-’~page.header.image_align) }}
{{ image|last.cropResize(400,400).html(’’,’’,‘align-’~page.header.image_align) }}
{% endif %}
1 Like

First of, thanks for the reply; its greatly appreciated Paul.

At first no go, error images showed.
clearing the cache made your code work.