This is my first Kirby project, so if you have any suggestions about how to filter/handle images, I am open to any kind of feedback. My project structure and the problem I am facing is as following:
I have dozens of pictures on my Homepage and need to filter these so that all pictures aren’t displayed in one files field. So I used file templates to group these pictures. They are successfully displaying on their own files fields.
Every image template group is numbered from 1_ on. This means that I have several image groups which have their own template, e.g. “home_background_image”, and they are numbered like mentioned. That is why I am using nth() to access images. They are numbered and each number will correspond to a specific place in my Home.php. For example, number 3 with the home_background_image template will always display as the third background image, even if the client replaces the image with a different name. What matters is the number 3_
The problem is, in my Home.php, I cannot filter these image according to template:
$page->images()->filterBy('intendedTemplate', 'home_background_image')->nth(1)->url()
Does not work. I tried many different versions of this, but filterBy seems to return null in every single case I tried. Can somebody help me with this? When clicking on the image in the panel I see the file fields, so the templates work. My homepage_background_image yaml is:
title: Homepage Background Image
fields:
alt:
label: Alt Text
type: text
Each image has a corresponding .txt file (1_home.jpg has 1_home.jpg.txt) with the simple following line:
template: homepage_background_image
Any feedback is greatly appreciated.