Results 1 to 6 of 6

Thread: PHP Photo Album script

  1. #1
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Photo Album script

    The script that I'm using is:
    http://www.dynamicdrive.com/dynamici...photoalbum.htm

    Now that I would wonder if I can use the file name of the image to replace "photo 1, photo 2... etc."?

    For example, I have photos with file name "apple.jpg", "orange.jpg" & "banana.jpg".
    I would like the description under the photo to be "apple", "orange" & "banana"; instead of "photo 1", "photo 2"...etc.

    Thanks a lot!

  2. #2
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    change
    Code:
    tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
    with
    Code:
    tempcontainer+=galleryarray[i][0].replace(/\..*$/, '')

  3. #3
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much, it works.

    Now I have installed and got it displayed decently.
    And I know in order to display the photo alphabetically, I can add this:

    galleryarray.sort()

    What if I want to display from the last to the beginning?
    For example I have A.jpg, B.jpg, C.jpg... etc.
    But I want to display from Z.jpg back to A.jpg?

    Thank you very much!

  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

    Code:
    function sortascend(a, b){ //Sort images function
    if (a[0].toUpperCase()<b[0].toUpperCase())
    return 1
    else if (a[0].toUpperCase()>b[0].toUpperCase())
    return -1
    return 0
    }
    
    galleryarray.sort(sortascend);
    - John
    ________________________

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

  5. #5
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    Code:
    function sortascend(a, b){ //Sort images function
    if (a[0].toUpperCase()<b[0].toUpperCase())
    return 1
    else if (a[0].toUpperCase()>b[0].toUpperCase())
    return -1
    return 0
    }
    
    galleryarray.sort(sortascend);

    Thanks...
    But where should I put the above script?

  6. #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

    Just substitute it for:

    galleryarray.sort()

    wherever you had that.
    - 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
  •