ok this is the full code with the <a>, just ignore the commented mess
for($i=0; $i<$rows; $i++) {
print('<tr>');
for($n=0; $n<COLS; $n++) {
$index = $GLOBALS['start']++;
// we either want the filename of the image, or
// an empty space to fill the rest of the table
$image = $index < $total ? $navtree[$index] : ' ';
print('<td align="center" width="'.THMBWIDTH.'" height="'.THMBHEIGHT.'">');
if($image != ' ') {
// this link provides the exact path to the
// image we want to display
print('<a href="'.$_SERVER['PHP_SELF']
.'?nav='.rawurlencode($GLOBALS['nav']
.'>'.$index).'">');
//echo "The Image Name: $image";
//echo "<img src=".PATH.rawurlencode($uri).$image." border='1' width='100' height='100'>";
// the img tag is making the call to our next
// script, imgsrc.php, which is being called
// with the full directory path to the image
echo "<img src='imgsrc.php?src="
.PATH.rawurlencode($uri).$image."' alt='$image' border='1' \>";
echo "</a>";
} else
echo "No Image ".$image;
echo "</td>";
}
echo "</tr>";
}
This is the imgsrc.php file:
require_once('config.php');
$src = isset($_REQUEST['src']) ? urldecode($_REQUEST['src']) : null;
// we're using file_exists here to prevent working with remote files
if(isset($src) && file_exists($src)) {
header('Content-Type: image/jpeg');
list($width, $height, $type, $attr) = getimagesize($src);
$img = imagecreatefromjpeg($src);
$lowest = min(THMBWIDTH / $width, THMBHEIGHT / $height);
if($lowest < 1)
{
$smallwidth = floor($lowest*$width);
$smallheight = floor($lowest*$height);
$tmp = imagecreatetruecolor($smallwidth, $smallheight);
imagecopyresized($tmp, $img, 1, 0, 0, 0, $smallwidth, $smallheight, $width, $height);
imagedestroy($img);
$img = $tmp;
}
imagejpeg($img, '', 100);
imagedestroy($img);
}
And this is the config file:
// main images directory
define('PATH', 'full/server/gallery/');
// valid file mime types, all other files will be ignored
define('TYPE', serialize(array('image/jpg', 'image/jpeg', 'image/pjpeg')));
// how many rows of images to display per page
define('ROWS', 3);
// how many columns of images to display per page
define('COLS', 5);
// maximum thumbnail width
define('THMBWIDTH', 100);
// maximum thumbnail height
define('THMBHEIGHT', 100);