This is a simple PHP insert that can be placed in any web page (if the server supports PHP.) It looks into a directory for pictures, then makes a thumbnail index with links to full-size pictures. With a simple HTML file and some basic CSS it generates pages like
this. If anyone wants I can post a sample web page and CSS to go along with this.
Code:
<!-- powered by Scott's amazing one-page Gallery_Builder © 2006 -->
<?php
echo "\n<!-- begin \"/includes/gallery_builder.php\" -->";
// The following 5 constant definitions need to be pasted into each gallery page.
// define ('COLS', 4); // number of columns to display in each row.
// define ('THUMB', 'thumbnails'); // name of directory where thumbnail images are stored.
// define ('IMAGE', 'full_size'); // name of directory where full-size images are stored.
// define ('TN_HEIGHT', 127);
// define ('TN_WIDTH', 170);
// $captions = FALSE; // or TRUE, uses image file name.
// $strip_front = 4; // number of character to strip from front of filename to generate captions.
// NOTE: thumbnails and full-size images MUST have the EXACT same names.
if ($dir = @opendir(THUMB)) {
echo "\n\t<table class=\"proofs\" cellspacing=\"0\">\n";
$pictures=array();
readdir($dir); // "./"
readdir($dir); // "../"
while (false !== ($imagename = readdir($dir))) {
array_push($pictures, "$imagename");
}
closedir($dir);
sort ($pictures);
$column = 1;
echo "\n";
foreach ($pictures as $image) {
if ($column == 1) { echo "\t<tr>\n"; }
$caption = (substr("$image", "$strip_front", -4));
$caption = (str_replace("_", " ", "$caption"));
if ($captions) {
if (!$strip_front) { $strip_front = 4; }
if (!$caption) {
echo "\t\t<td><img src=\"" . THUMB . "/$image\" \n\t\t\talt=\"$image\" title=\"$image\" width=\"" . TN_WIDTH . "\" height=\"" . TN_HEIGHT . "\" /><br />$caption</td>\n";
} else {
echo "\t\t<td><a href=\"" . IMAGE . "/$image\"><img src=\"" . THUMB . "/$image\" \n\t\t\talt=\"$image\" title=\"$image\" width=\"" . TN_WIDTH . "\" height=\"" . TN_HEIGHT . "\" /></a><br />$caption</td>\n";
}
} else {
if (!$caption) {
echo "\t\t<td><img src=\"" . THUMB . "/$image\" \n\t\t\talt=\"$image\" title=\"$image\" width=\"" . TN_WIDTH . "\" height=\"" . TN_HEIGHT . "\" /></td>\n";
} else {
echo "\t\t<td><a href=\"" . IMAGE . "/$image\"><img src=\"" . THUMB . "/$image\" \n\t\t\talt=\"$image\" title=\"$image\" width=\"" . TN_WIDTH . "\" height=\"" . TN_HEIGHT . "\" /></a></td>\n";
}
}
$column++;
if ($column > COLS) { $column = 1; echo "\t</tr>\n";
}
}
if ($column != (COLS + 1)) { echo "\t</tr>\n"; }
echo "\n\t</table>\n";
} else {
echo '<h2 style="color: #F00;">We couldn\'t find a folder named "' . THUMB . '"</h2>';
}
echo "<!-- end \"/includes/gallery_builder.php\" -->\n";
?>
Feel free to use as you wish.
--scott