Reply to Getting Image File Listing Script to work with Lightbox Effect

Your name:

Reply:


Posted by Steve on 12/06/07 03:20

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




<?php
$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 "<a href=\"http://www.mywebsite.com/testdir/$a_img[$x]\"
rel=\"lightbox[imagesetgroupname]\" title=\"my caption\"><img
src=\"http://www.mywebsite.com/testdir/$a_img[$x]\" /></a><br />";
}
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация