Ordering images by date created

Hi folks! I’m doing a thing on my site where I upload a painting of an egg most days to a content folder in Kirby, and get Kirby to read those files and display them.

I’m trying to make this is as quick and simple as possible, and not have a folder/post per entry, but rather just get Kirby to show all the images in that folder. Each one is named with the date (such as 01.02.21) which is used for ordering and as a title) The only other I’m doing is to add a text file for each image with the alt text and caption.

At the moment I’m using this:

<?php foreach($page->images()->flip() as $image): ?>

Which has worked well for ordering them via the filename, until today. ‘01.02.21’ is shown next to ‘01.01.21’ which is of course, as I should’ve expected. Is there a way of ordering the eggs without adding another field, or more complexity?

Having a nose around the forum, I tried this which is close:

<?php foreach($page->images()->sortBy('modified', 'desc') as $image): ?>

But as some images were updated, the order is wrong, and yet is also wrong with ‘created’. Any pointers?

If you chage the filename to yyyy-mm-dd format (or without the dashes) instead, you won’t run into this issue.

Doh! Of course, thanks!