Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Images should be sorted by filename but it seems random or by date(?)

Started by Japhy 7 years ago · 1 replies · 754 views
7 years ago

I searched the forum and found some similar but old topics and not really an answer why this is happening.

I have many galleries, and upload many images to a single post. In the backend images are not sorted by filename. It seems random, maybe date. My galleries show pictures in the same order.

I always use the same naming scheme as to avoid order problems

2019-06-15-Image1
2019-06-15-Image2
2019-06-15-Image3
2019-06-14-Image1
2019-06-14-Image2
2018-07-12-Images....
Etc

Other naming schemes don't work as expected either. Any ideas?

regards

7 years ago

Maybe it has something to do with the PHP asort function

Anyway I solved it in my gallery template twig...in case someone stumbles upon this post.

This orders them from new to old (in my case)

{% for image in page.media.images|sort|reverse %}

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago