Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

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

Started by Japhy 7 years ago · 1 replies · 431 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 Jerry Hunt, 4 days ago
2 99 16 hours ago
General · by pamtbaau, 21 hours ago
1 63 21 hours ago
General · by Andy Miller, 1 day ago
0 48 1 day ago
General · by Marcel, 12 months ago
6 357 5 days ago
General · by Duc , 6 days ago
3 45 6 days ago