Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

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

Started by Japhy 7 years ago · 1 replies · 576 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 jeremycherfas, 1 week ago
5 195 3 hours ago
General · by lynbor, 6 days ago
2 129 3 days ago
General · by Old Man Umby, 1 week ago
1 103 1 week ago
General · by Sebastian, 2 weeks ago
1 128 2 weeks ago
General · by Andy Miller, 3 weeks ago
0 251 3 weeks ago