Getting Image File Listing Script to work with Lightbox Effect

Getting Image File Listing Script to work with Lightbox Effect

am 06.12.2007 04:20:39 von DFS

Hi there,

I've got a php script which searches for images within a certain
directory and outputs the file listing. I've edited the echo statement
so that the images are displayed on the page, and they also open within
a lightbox image set
(http://www.huddletogether.com/projects/lightbox2/).

I'd really apprecate it if someone could help me modify the code below
so that I can echo the first image so that it has a unique hyperlink,
then the remaining images to be displayed with a slightly different
hyperlink. What I'm trying to do is to echo the first image so that
only this image displays on the page. I'd then like to echo the
remaining images so that these images don't display as images, but
instead, display within the source code only - this means that the user
can click the first image (the only image visible on the page) and it
then opens in a lightbox and they can click next/previous to cycle
through all the other images.

I know how to do this by hard coding it manually, but don't know how to
edit the php script to display the first image in a certain format,
then the remaining images in a different format.

Thanks for any help, and here's the script.

Thanks,

Steve




$imgdir = 'testdir/'; // the directory, where images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes
you want to show
$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);
}
}
$totimg = count($a_img); // total image number
for($x=0; $x < $totimg; $x++)
{
echo " rel=\"lightbox[imagesetgroupname]\" title=\"my caption\"> src=\"http://www.mywebsite.com/testdir/$a_img[$x]\" />
";
}
?>