Page 1 of 1
Preloading a directory
Posted: Fri Jun 21, 2002 5:40 am
by Kriek
Is there anyway to preload all the images from one directory? vs. typing each file name in on a preload script?
I was reading up on the
Directory functions , but haven't found what I'm looking for.
Posted: Fri Jun 21, 2002 6:06 am
by kaizix
well, the
readdir will read out the next filename in the dir (after you've
opened it)...you could probably use that code to list all the files in the directory and put them into an array from which you could preload them however you choose.
Posted: Fri Jun 21, 2002 7:48 am
by Kriek
That's a pretty good theory. Never would have thought of it.
I'll fool around with that and see if I can come up with something.
If anyone gets it working before me please post it.
Posted: Fri Jun 21, 2002 9:38 am
by will
i wrote a script to automatically build a thumbnail table of all the images in a given directory.... a few snippets from that and you get this, which should do what you're asking for....
Code: Select all
function preload_dir($dir)
{
$d = dir($dir);
#echo "Handle: ".$d->handle."<br>\n";
#echo "Path: ".$d->path."<br>\n";
while (false !== ($entry = $d->read())) {
// edit statement below to include desired extensions
if (ereg("((jpg)|(gif))$i",$entry)) {
// edit this to print whatever
// javascript will do the preload trick
echo $entry."<br>\n";
}
}
$d->close();
}
this will only print the name of the image, but that can be replaced with your javascript statement for each image. you can also edit it to work with whatever extensions you want (currently is only *.jpg and *.gif). the present script will also require a full path to the directory... adding a little $DOCUMENT_ROOT would fix that.
if that's not what you need, lemme know.
feed me!
Posted: Wed Nov 06, 2002 12:48 pm
by hellfish
Could you please let me see your script for the thumbnails, I've been looking for something like that that doesn't use GD library.
But still in the topic, how can I build a page that I can actually se the preload in action, how can I tell if it is really working?