I wrote a neat little script to simply read a directory, search for thumbnails, then print a list with links to the larger images. I look for the thumbnails so it doesn’t get images that don’t have small versions.
There are limitations, for example if you put a PDF with ‘.thumb’ in the directory it will try to link it as an image. This is ok for me because I’m controlling what goes in the directories. I suppose I could add a check for it later if I need to.
<?php
/* This little snippet takes the directory and looks for any files with ‘.thumb’. Then it takes out the ‘.thumb’ to link to the big image. Then it makes a nice little list. */
$dir = ‘gallery/gallery2/’; /* Point to the right gallery directory */
echo “<ul>”;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) { /* Loop over directory */
if (strpos($file, ‘.thumb’)) { /* Look for the .thumb */
$filebig = str_replace(’.thumb’,”,$file); /* Remove .thumb for our big files */
echo “<li><a href=\”$dir$filebig\” rel=\”lightbox[1]\”><img src=\”$dir$file\” border=\”0\”/></a></li>\n”; /* Make the list with both file names */
}
}
closedir($handle); /* Finish */
}
echo “</ul>”
?>