Hello,
I’m pulling all the images from all the children pages of a page using a foreach loop.
A same image might be used several times across those children pages.
Is there a way I can skip if an image is repeated and only show all the images once?
Can this perhaps be accomplished via ->filterBy('filename', '*=', '...')?
What I need is to basically tell Kirby to skip duplicated image files.
Yes (note that I changed the position of the if statement to prevent an empty div in case the image doesn’t exist and remove an unnecessary if statement (checking if the image field is empty is not necessary, because you also check for an image object and you won’t have one if the field is empty)
Thanks a lot.
I needed to change <?php $filenames[] = $image->filename(); ?> for <?php $filenames[] = $thumb->filename(); ?> in order to make this work.
After that, working like a charm.
I really appreciate the help!