PDA

View Full Version : Slideshow galleryarray problems



CanCon
04-19-2011, 06:49 PM
1) Script Title: Ultimate Fade-In Slideshow (v2.4)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.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!

jscheuer1
04-19-2011, 07:48 PM
If you only want to reverse the order, do:


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:


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:


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

CanCon
04-28-2011, 08:50 PM
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.

jscheuer1
04-29-2011, 02:21 AM
<?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();
?>

CanCon
05-02-2011, 09:07 PM
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!