Results 1 to 5 of 5

Thread: Slideshow galleryarray problems

  1. #1
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Slideshow galleryarray problems

    1) Script Title: Ultimate Fade-In Slideshow (v2.4)

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

    3) Describe problem: I've modified the script to call images from a folder, so

    imagearray: [
    ["http://i26.tinypic.com/11l7ls0.jpg", "", "", "Nothing beats relaxing next to the pool when the weather is hot."],
    ["http://i29.tinypic.com/xp3hns.jpg", "http://en.wikipedia.org/wiki/Cave", "_new", "Some day I'd like to explore these caves!"],
    ["http://i30.tinypic.com/531q3n.jpg"],
    ["http://i31.tinypic.com/119w28m.jpg", "", "", "What a beautiful scene with everything changing colors."] //<--no trailing comma after very last image element!
    ],

    becomes

    imagearray: galleryarray,

    Nothing new there, right? Works like a dream, but it presents two problems:

    1) The array displays in reverse alphabetical/numerical order

    2) The description field disappears, and I'm not sure if I can add descriptions when calling from galleryarray

    Please forgive a newb if this has been beaten to death, but I honestly could not find solutions to these problems. Thanks for reading!

  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

    If you only want to reverse the order, do:

    Code:
    imagearray: galleryarray.reverse(),
    Or instead, and this might work better with using javascript descriptions as described below, do this before that and do both before the var mygallery = new fadeslideshow({ line:

    Code:
    galleryarray.reverse();
    If you want descriptions, you can have the server side script (PHP, is it?) that generates the array, make one with descriptions. That's if it can pull something from each file to use as the description. What's the server side script you're using look like?

    You could pull the filename without extension for instance. If these image files' format support descriptions, many do, and you have these description fields in these image files filled out, PHP might be able to pull those. Or you could add the descriptions using javascript:

    Code:
    galleryarray[0][3] = "A pleasant walk in the park";
    galleryarray[1][3] = "The sky was beautiful that day";
    galleryarray[2][3] = "Sometimes the dog walks the person";
    galleryarray[3][3] = " . . . etc. . . .
    - John
    ________________________

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

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

    CanCon (04-28-2011)

  4. #3
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks, John. The galleryarray.reverse(), was exactly what I needed there. As for the descriptions, echoing the filename without extension would be perfect. I used PHP code right from this very site:

    <?php
    Header("content-type: application/x-javascript");

    function returnimages($dirname="./Proof1/") {
    $pattern="\.(jpg|jpeg|png|gif|bmp)$";
    $files = array();
    $curimage=0;
    if($handle = opendir($dirname)) {
    while(false !== ($file = readdir($handle))){
    if(eregi($pattern, $file)){
    echo 'galleryarray[' . $curimage .']=["' . $dirname . $file . '"];' . "\n";
    $curimage++;
    }
    }

    closedir($handle);
    }
    return($files);
    }

    echo "var galleryarray=new Array();" . "\n";
    returnimages();
    ?>

    Hope that's what you're looking for. As I said, having the filename show up in the description is exactly what I need. Thank you for your help, and please forgive my newbness. Basically, you have an HTML Ace, but a PHP/Javascript Joker, on your hands, so thank you for your patience as well.

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

    PHP Code:
    <?php
     Header
    ("content-type: application/x-javascript");

     function 
    returnimages($dirname="./Proof1/") {
     
    $pattern='/\.(jpg|jpeg|png|gif|bmp)$/i';
     
    $files = array();
     
    $curimage=0;
     if(
    $handle opendir($dirname)) {
     while(
    false !== ($file readdir($handle))){
     if(
    preg_match($pattern$file)){
     echo 
    'galleryarray[' $curimage .']=["' $dirname $file '", "", "", "' preg_replace($pattern''$file) . '"];' "\n";
     
    $curimage++;
     }
     }

     
    closedir($handle);
     }
     return(
    $files);
     }

     echo 
    "var galleryarray=new Array();" "\n";
     
    returnimages();
     
    ?>
    - John
    ________________________

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

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

    CanCon (05-02-2011)

  7. #5
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Wow, just like that! I really need to learn my PHP. That was exactly the ticket, John. Thank you. Next time I'll have to give you a real challenge!

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
  •