Hi,
I’m trying to use the ->shuffle()
function to get a random image from my homepage blueprint.
I have created the under the folder site/blueprints/pages/ a home.yml inside. I have differents tabs, with some text fields, files fields and so on.
I want to use the shuffle on that particular files fields:
fields:
gallery:
label:
fr: galerie
en: Gallery
type: files
accept: image/jpeg, image/png, image/gif
layout: cards
template: image
translate: false
To output the random image I use the following code:
$site->homePage()->gallery()->shuffle()->first()->toFile();
But the same and first image always appears… Because I have other images in the others tabs I can’t use the ->images()
instead of the ->gallery()
Any help would be grateful!