Aha... I have it.
ReplacewithCode:if(strpos($file, ".") === 0) continue;Oh, and the slash isn't necessary, I've no idea why I said it was.Code:if(strpos($file, ".") === 0) { $i--; continue; }![]()
Aha... I have it.
ReplacewithCode:if(strpos($file, ".") === 0) continue;Oh, and the slash isn't necessary, I've no idea why I said it was.Code:if(strpos($file, ".") === 0) { $i--; continue; }![]()
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
The PHP file now reads:
<?php
// getpics.php
$directory = "Graphics/Thumbnails"; // Directory in which the images are stored, relative to the location of this script. Must have the slash.
header("Content-Type: text/javascript");
$dir = opendir($directory);
for($i=0;$file = readdir($dir);$i++)
if(strpos($file, ".") === 0) {
$i--;
continue;
}
and I uploaded it.
However, the page still generates errors:
http://www.protestantlawyersny.org/test.htm
I'm hopeless!
You missed half the script off the end. I'm not surprised.
It should read:Code:<?php // getpics.php $directory = "."; // Directory in which the images are stored, relative to the location of this script. Must have the slash. header("Content-Type: text/javascript"); $dir = opendir($directory); for($i=0;$file = readdir($dir);$i++) if(strpos($file, ".") === 0) { $i--; continue; } else echo("fadeimages[$i]=['$directory/$file', '', ''];\n"); ?>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Twey,
I'm extremely grateful for your solution.
It does have a couple of issues:
1- I no longer can show two pictures side by side
(the second array doesnt seem to load)
2- there is an error generated on the page
3- the link effect on each pic is no longer enabled (not that I really see a need for such an effect).
The link for the page is:
http://www.protestantlawyersny.org/test.htm
Nelson
There is no way my script can tell to whence you wish it to link. You'd have to enter the links manually, and my reasoning was that in that case you might as well do the images manually as well.3- the link effect on each pic is no longer enabled (not that I really see a need for such an effect).
As for the other two, you need to save the PHP script as a different file, and edit the variable name it outputs.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Ahhh, thank you Twey.
Thanks to you, the script works very well and loads all the photos in the directory.
http://www.protestantlawyersny.org/test.htm is the page demo for any looking to modify the ultimate fade in slideshow to load an entire directory rather than specified filenames.
I needed to specify the entire directory because the photographer who took the photos digitally gave them very long filenames (12 digits) and entering them individually was a major headache.
One final question -
While it may be impossible to add a link to each photo now, is there a way to add something to your PHP script so that I can add just ONE url to any photo that is loaded so that the user can click on ANY photo and get to the photo gallery page where all the photos are kept? If it isn't possible, no biggie, I was just wondering.
Thanks.
Learning a lot...
Nelson
Of course -- just put the URL to your photo gallery inside the first empty pair of quotes.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Twey:
The PHP script works wonderfully- thanks.
However, it does tend to slow down the loading of the page.
I need some sort of preloader that can be added to the PHP script to preload the entire directory of images.
I found this PHP preload script on the net:
<?
$my_directory = ("Your Directory");
$dir = dir($my_directory);
while($temp = $dir->read())
{
$dirarray[] = $temp;
}
print j_array($dirarray);
function j_array($var){
$javastr = "<script language=\"javascript\">";
$javastr .= "var d = new Array();";
$diro="Pictures/";
while(list($key, $val) = each($var)){
$javastr .= "d[$key] = new Image();";
$javastr .= "d[$key].src = '$diro$val';";
}
$javastr .= "</script>";
return $javastr;
}
?>
Can this code be integrated into your PHP script. If so, how would I do it? If not, is there a way that I can run this on my test page so that the images from both slideshows will be preloaded first? The end result would be a MUCH improved fading slideshow that PRELOADS all images and then runs ALL images from a given folder or directory.
Thanks!
Nelson
http://www.protestantlawyersny.org/index.htm
Of course...Include it in the head of your page:Code:<?php // getpics.php $directory = "."; // Directory in which the images are stored, relative to the location of this script. header("Content-Type: text/javascript"); $dir = opendir($directory); for($i=0;$file = readdir($dir);$i++) if(strpos($file, ".") === 0) { $i--; continue; } else if(isset($_GET['preload'])) { echo("(new Image()).src = '$directory/$file';\n"); } else echo("fadeimages[$i]=['$directory/$file', '', ''];\n"); ?>Code:<script type="text/javascript" src="getpics.php?preload"></script>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I'm getting an error.
I installed it in the test.htm file as before:
http://www.protestantlawyersny.org/test.htm
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
</script><script type="text/javascript" src="getpics2.php?preload"></script><script>
var fadeimages2=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
</script><script type="text/javascript" src="getpics3.php?preload"></script><script>
var fadebgcolor="#000066"
////NO need to edit beyond here/////////////
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
and the two versions of the PHP file are:
<?php
// getpics.php
$directory = "Graphics/Installation_2006/Thumbnails/"; // Directory in which the images are stored, relative to the location of this script.
header("Content-Type: text/javascript");
$dir = opendir($directory);
for($i=0;$file = readdir($dir);$i++)
if(strpos($file, ".") === 0) {
$i--;
continue;
} else if(isset($_GET['preload'])) {
echo("(new Image()).src = '$directory/$file';\n");
} else echo("fadeimages[$i]=['$directory/$file', '', ''];\n");
?>
and
<?php
// getpics.php
$directory = "Graphics/Installation_2006/Thumbnails/"; // Directory in which the images are stored, relative to the location of this script.
header("Content-Type: text/javascript");
$dir = opendir($directory);
for($i=0;$file = readdir($dir);$i++)
if(strpos($file, ".") === 0) {
$i--;
continue;
} else if(isset($_GET['preload'])) {
echo("(new Image()).src = '$directory/$file';\n");
} else echo("fadeimages2[$i]=['$directory/$file', '', ''];\n");
?>
The error is generated when I add the preload function to the script command: "?preload".
I have two slideshows running simultaneously, side by side.
I am kind of lost.
Nelson
Last edited by nelsontimken; 06-13-2006 at 11:31 AM.
Bookmarks