Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: PHP Photo Album script case insensitive

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default PHP Photo Album script case insensitive

    1) Script Title: PHP Photo Album script v2.11

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...photoalbum.htm

    3) Describe problem: What should I change to get the script to sort by filename and be case insensitive?
    Last edited by james438; 12-07-2009 at 03:32 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It already does.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Laintest.JPG is listed right before akira.jpg. I am pretty sure this is because it is case sensitive.
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, I tested the method used and it was case insensitive here. However, if you are having problems, replace:

    Code:
    	if (setting.sortby[0]=="file") //sort by filename (asc)
    		this.albumvar.images.sort(function(a,b){return a[1].localeCompare(b[1])})
    with:

    Code:
    	if (setting.sortby[0]=="file") //sort by filename (asc)
    		this.albumvar.images.sort(function(a, b){return a[1].toLowerCase() > b[1].toLowerCase();})
    Are you sure you are sorting by ['file', 'asc'] and have made no changes to getalbumpics.php?

    Code:
    new phpimagealbum({
    	albumvar: myvacation, //ID of photo album to display (based on getpics.php?id=xxx)
    	dimensions: [3,2],
    	sortby: ["file", "asc"], //["file" or "date", "asc" or "desc"]
    	autodesc: "Photo %i", //Auto add a description beneath each picture? (use keyword %i for image position, %d for image date)
    	showsourceorder: true, //Show source order of each picture? (helpful during set up stage)
    	onphotoclick:function(thumbref, thumbindex, thumbfilename){
    		thumbnailviewer.loadimage(thumbref.src, "fit2screen")
    	}
    })
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    james438 (12-02-2009)

  6. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    That worked.

    I did make a few changes prior to starting this thread.

    I used
    Code:
    desc=(desc.indexOf('%filename')!=-1)? '<br />/images/' + albumvar.images[i][1] : desc
    after
    Code:
    var desc=(desc && desc!="")? '<br />' + desc.replace(/(%i)|(%d)|(%s)/g, function(m){
    return (m=="%i")? i+1 : (m=="%d")? albumvar.images[i][2] : ""
    }) : ''
    and when I updated from 2.0 to 2.11 I only updated the ddphpalbum.js file. Maybe it was a problem with my php.ini?
    Last edited by james438; 12-02-2009 at 07:19 PM. Reason: grammar
    To choose the lesser of two evils is still to choose evil. My personal site

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I did a little more research on this localeCompare() method used by the script. It is non-standard, varies by those browsers that do support it, as well as by what the language (English, German, French, etc.) is in effect on the local computer.

    So it may be nothing you did to your PHP or script code.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #7
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Yes. When I tested the script in Opera, Firefox, and IE8 only Opera sorted in a case sensitive manner.
    To choose the lesser of two evils is still to choose evil. My personal site

  9. #8
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Odd. I looked again and your fix did not work and it is still an Opera problem. Opera puts the order of results as:
    PHP Code:
    /images/alita5.jpg
    /images/akira.jpg
    /images/alita1.jpg
    /images/alita2.jpg
    /images/alita3.jpg
    /images/alita4.jpg
    /images/alita6.jpg 
    I seem to be having a number of issues with the Opera browser lately.
    To choose the lesser of two evils is still to choose evil. My personal site

  10. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    By coincidence Opera is my primary browser for surfing the web, although Firefox is configured on my system as the primary browser - available as the default for preview of any web page in my editor or double clicked in my windows explorer (different than internet explorer). I like Firefox for this due to its superior IMO diagnostics of both javascript and HTML code.

    Anyways, as a confirmed Opera user, I also use it and its excellent AI for email. At the same time though I am aware of its many quirks as regards, well just about everything. I think most Opera users are aware of this as well, and accept it as a trade off for the added security and features Opera provides.

    One consolation though, as regards this script, because the image array produced still carries with it its original index at the time it was fetched from the image folder, most things you do with the images will still 'work out', regardless of what order your sorting algorithm places them in.

    Is there any particular problem that arises from Opera's different take on the sort? If so, there is almost certainly a workaround, though it may or may not not be simple.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  11. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm thinking about this a bit more. If you want you can give me a link to your page and I'll see if I can figure an Opera fix. In the mean time I'll do some tests to see if I can get Opera to duplicate the behavior you are reporting.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •