This page demonstrates the new (from Thumblist² on) parameter to sort the files displayed in the thumblist.
Here are the files:
In the old version, the list was always sorted by the filename, or shuffled. It is now possible to sort also by extension, file last modified time, file size, width, height and ratio, with the parameter
order=. If you use a "minus", like
order=-time, the filelist will be reversed.
It is also possible to write your own sorting functions, see below.
Note that when a thumblist displays only a part of all files in the upload directory (with
count=X..Y), ordering the files by time, size, width, height and ratio may be noticeably slower, as the script will need to open every file in the upload directory in order to read this additional information. If you are not using
count=, then the speed is about the same.
No order specified (same as order=name, because it was the default behavior in previous versions):
You can change the default order by adding in your config.php for example:
$ThumbList['FileListOrder'] = '-time';
Note: the files are uploaded to a group Order, that's why the lines start with "thumblist Order.".
order=none (should be what returned the directory listing, FASTEST):
order=-name (reversed sort by filename):
order=ext (.gif, then .jpg, then .png):
order=ratio orders by width/height:
order=random (see Shuffle for details):
With a thumbgallery the images are displayed in the order they are defined.
Write your own sort function
This is an advanced topic. If you don't understand everything here, it is advisable not to write the function yourself (we can write it for you).
Thumblist² comes with a really flexible code and numerous hooks to enable your own features. There are two ways to do it:
(Advanced.) Write a user function similar to ThumbOrderFileList(), for example "uThumbOrderFileList()" and set in config.php
$ThumbList['fOrderFileList'] = 'uThumbOrderFileList';
(Easier.) Write a short callback function and place it in the $ThumbList['OrderFunctions'] array (see how it is done).
For example, if you want to sort the files by area (square pixels), here is what you will do:
# force a getimagesize() on the file, for the order=area parameter $ThumbList['stat_dirlist']['area'] = 'getimagesize'; # define the order function $ThumbList['OrderFunctions']['area'] = '$c=$a["getimagesize"];$d=$b["getimagesize"]; return $c*$c-$d*$d;';
And the result is:
Multiple ordering, unrecognized order functions
Ordering by two or more order functions, or by a function that is not recognized, is not supported and is ignored (
order=name is used instead, no error message is given).