Loop over all files of a file section

Hi there,
sorry, I feel like this is a really basic question, but I am totally lost after not using Kirby for a few weeks. :pensive:

In my page blueprint I have a file section defined which allows me to upload images and videos. I now want to loop over the files of this file section and this section only. I have no idea how to do that actually.

Here is my blueprint code for the section:

        headline: Bilder & Videos
        type: files
        layout: cards
        size: tiny
        template: media
        empty: Noch keine Bilder oder Videos hinzugefügt.

Note that the media template refers to images and videos. However there are some images in the content folder that are not in the files section (automatically generated thumbnails of the videos) and that I do not want to loop over.

Do I need to loop over all files of the page and then have an extra check, if they have the correct template? Or is there a direct way to loop over a specific file section?

Thank you!

No. But you can filter your files by template:

$mediaFiles = $page->files()->template('media');

Which is a shortcut for

$mediaFiles = $page->files()->filterBy('template', 'media');
1 Like

Ah, okay, perfect. That will do of course. Thank you!