Avatars in Gallery are Unsorted

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Avatars in Gallery are Unsorted

Post by MxAlex »

For some reason, the avatars in the local galleries I've uploaded are not sorted by filename or upload date, and are instead organized completely randomly. I have found topics going back 15~ years about this issue, including other support topics, but for the life of me, I cannot find a posted solution to fixing this that looks like it'll work with 3.3.9. Some of those topics seemed to indicate that the avatars should be sorted alphabetically, but for some reason this isn't happening. I can't find any existing bug reports on it though.

All of my avatars are located within a subfolder/'category', named cn_###.png, going from cn_001.png to cn_159.png. I tried uploading them in specific orders, but that did not affect the way they are displayed either. It is the same order every time, that does not change. I would like them to be displayed alphabetically/numerically, as the images are based on trading cards in a set; they are organized by their card number, and so I want the 'first' card (001/159) in the set to be the first card displayed, etc. I do know the relevant file is /avatar/driver/local.php, but I don't know enough about php works out how to modify the sorting myself unfortunately.

Here is a screenshot demonstrating how the file names/numbers are out of order;

Image

Any help is extremely appreciated, thank you.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26514
Joined: Fri Aug 29, 2008 9:49 am

Re: Avatars in Gallery are Unsorted

Post by Mick »

MxAlex wrote: Fri Jan 27, 2023 4:44 amIt is the same order every time, that does not change
That in itself would tell me it’s not random placement. In fact it’s more probably whatever order your host serves up the files.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Re: Avatars in Gallery are Unsorted

Post by MxAlex »

Mick wrote: Fri Jan 27, 2023 9:13 am
MxAlex wrote: Fri Jan 27, 2023 4:44 amIt is the same order every time, that does not change
That in itself would tell me it’s not random placement. In fact it’s more probably whatever order your host serves up the files.
Yes, that's more or less what other topics I found on the subject said - the problem is that nobody seems to know what that is, and I don't know how to change that. I'd like them to be in alphabetical/numerical order.
User avatar
lurttinen
Translator
Posts: 4728
Joined: Tue Sep 21, 2004 12:05 pm

Re: Avatars in Gallery are Unsorted

Post by lurttinen »

I have no way testing this and might be wrong but apache has a IndexOrderDefault directive to change the order stuff is listed. (with mod_autoindex, you can see if it is loaded from php information in ACP-system)

You need to set it up in apache2.conf

Code: Select all

<Directory /where/your/www/is/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>
Add IndexOrderDefault Ascending Name

Or in .htaccess in your forum root directory. (If you have .htaccess enabled)

options are IndexOrderDefault Ascending|Descending Name|Date|Size|Description

I might be wrong here, but if the list is provided to you by your operating system, then there surely is a way to modify how your webserver gives it to you. ;)

EDIT: if you test this, remember to clear cache to see results.
Signature is here
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Re: Avatars in Gallery are Unsorted

Post by MxAlex »

lurttinen wrote: Sat Jan 28, 2023 1:03 am

Code: Select all

<Directory /where/your/www/is/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>
Add IndexOrderDefault Ascending Name

Or in .htaccess in your forum root directory. (If you have .htaccess enabled)

options are IndexOrderDefault Ascending|Descending Name|Date|Size|Description
I am assuming I'd need to put the avatar gallery directory link in /where/your/www/is/ is, or somewhere else? Sorry, I am more of a CSS person than anything, I don't know a lot of PHP and nothing really of apache (':
User avatar
lurttinen
Translator
Posts: 4728
Joined: Tue Sep 21, 2004 12:05 pm

Re: Avatars in Gallery are Unsorted

Post by lurttinen »

If you cannot edit server configuration files, then you should add IndexOrderDefault Ascending Name in .htaccess file in your website root directory.
.htaccess is a hidden file (because it starts with dot) so you might need to set your FTP program to show hidden files.

Apache2.conf is usually located in /etc/apache2/apache2.conf outside your web files. Add it to your correct path you see there.

Code: Select all

<Directory /where/your/www/is/>
        Options Indexes FollowSymLinks
        IndexOrderDefault Ascending Name
        AllowOverride None
        Require all denied
</Directory>
With this you are not actually programming anything, but configuring your server.

I forgot to mention, that if you edit server configuration, you need to restart server for the changes to take effect. :lol:
The command to restart server depends your operating system, so just reboot it.. ;) That should not take long to come back online.
Signature is here
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Re: Avatars in Gallery are Unsorted

Post by MxAlex »

lurttinen wrote: Sat Jan 28, 2023 2:41 am If you cannot edit server configuration files, then you should add IndexOrderDefault Ascending Name in .htaccess file in your website root directory.
.htaccess is a hidden file (because it starts with dot) so you might need to set your FTP program to show hidden files.
I am on shared hosting at the moment, so I don't think I have a lot of access to any of the server configuration stuff. I went with your .htaccess idea, but that does not seem to be working; I added it to my main root directory's .htaccess file, and then cleared my browser's cache and cleared the cache from the ACP, and hard refreshed with no change. I then tried adding a .htaccess file to the gallery folder shown in the screenshot, and did the same clearing - still nothing, unfortunately.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26514
Joined: Fri Aug 29, 2008 9:49 am

Re: Avatars in Gallery are Unsorted

Post by Mick »

It seems simple enough, your host should be able fix it for you.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Re: Avatars in Gallery are Unsorted

Post by MxAlex »

So this just can’t be modified through coding? That seems a little unusual, but sure, I will reach out to my host and see what they can do.
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 28651
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Avatars in Gallery are Unsorted

Post by Paul »

The sort is, of course, done in coding. By default it is done at https://github.com/phpbb/phpbb/blob/3.3 ... l.php#L197
By the looks of it you will need to sort the inner array to sort it properly.
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Re: Avatars in Gallery are Unsorted

Post by MxAlex »

Paul wrote: Sat Jan 28, 2023 7:12 pm The sort is, of course, done in coding. By default it is done at https://github.com/phpbb/phpbb/blob/3.3 ... l.php#L197
By the looks of it you will need to sort the inner array to sort it properly.
This was what I was originally looking at, but I am not sure how to do that - my limited php work hasn't really touched arrays. If I did try, is that the only part/line that I would need to modify?
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26514
Joined: Fri Aug 29, 2008 9:49 am

Re: Avatars in Gallery are Unsorted

Post by Mick »

What I’m not getting is why would the host and or phpBB choose to sort in such a nonsensical way? Surely, if you’re going to the bother to sort something use a method that people can use like alphabetical, numeric or none for example?
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
User avatar
lurttinen
Translator
Posts: 4728
Joined: Tue Sep 21, 2004 12:05 pm

Re: Avatars in Gallery are Unsorted

Post by lurttinen »

htaccess trickery did not work, but i sort of found a way to do it. :lol:
4231.jpg
to
1234.jpg
Files are named
1.jpg
2.jpg
3.jpg
4.jpg

Original only 1 and 4 were misplaced so just renamed them as 4 and 1 to set correct order 1234.

They are not displayed with file size either, as 4231 went
1673
1950
1720
1445

Therefore, start renaming your files if it helps.. :lol:
Signature is here
MxAlex
Registered User
Posts: 14
Joined: Fri Apr 03, 2020 5:03 am

Re: Avatars in Gallery are Unsorted

Post by MxAlex »

That... is a bizarre solution. How does that work?? It's not really feasible for me, as their names are specific for a reason but why it's doing this, I don't know... O.o
Last edited by Mick on Fri Feb 03, 2023 8:59 pm, edited 1 time in total.
Reason: Removed unnecessary full quotes.
User avatar
Anișor
Translator
Posts: 273
Joined: Tue Jan 08, 2013 9:36 pm
Location: Arbroath, Angus, Scotland
Contact:

Re: Avatars in Gallery are Unsorted

Post by Anișor »

Not recommended but … in the file Paul linked above change
ksort($avatar_list);
With:
natsort($avatar_list);
Until you find a better solution that doesn’t require core code change.
Purge the cache after.
Last edited by Anișor on Mon Feb 06, 2023 4:46 pm, edited 3 times in total.
Formerly known as Neculai Anisor
Discord: Criminus#1996
Post Reply

Return to “[3.3.x] Support Forum”