Edit: That's not exactly so, Tommisauce and boogyman. It should be, but read on . . .
Strange, isn't it? The default sorting method is set in the script as (from the demo Step 2):
Code:
//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"
in its configuration area. This means that the files will be sorted according to their date/time stamp in descending order, descending - I guess that means from biggest (most recent) to smallest (oldest), but to be frank I am only on my second cup of coffee, so it might be the other way around.
I don't need any coffee to tell you that the date/time stamp on the files are occasioned by their being uploaded to the server, and perhaps by being altered in some way once they are there, but uploading is the one part you can be certain of having control over.
So, you can upload the files one by one to (an empty directory on) the server, and that will be the order they will sort in, either froward or reverse of that. If you want to reverse it after uploading the files, just change this in the script:
Code:
var gsortorder="asc"
Unless you want to go through all that, which can have its merits in certain situations, but that is otherwise very cumbersome, you can sort alphabetically.
Unfortunately, where it says:
//"" disables this feature, so images are sorted by file name (default)
which should mean that doing this:
will sort in alphabetical order, is just not true. That's just not how the subsequent code was actually written.
If you are interested in sorting that way, set that variable empty like it says to do, and also add to the script here (addition red):
Code:
/////No need to edit beyond here///////////////////
function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}
if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)
else
galleryarray.sort();
var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagec . . .
That will sort the files by filename A to Z to a to z, so make sure the names are all lower case. Numbers in the filenames will be treated as letters sorted alphabetically, not mathematically.
It can be made to sort the names mathematically if desired, but that means that letters in the filenames might mess everything up, and I think you have enough to go on now. And I want that third cup of coffee!
Bookmarks