Hey, I'm building a website for my friend - I'm having trouble trying to display a thumbnail gallery...
I want to make it so I can create a gallery from a folder full of images... And add more by just dumping more into the folder.
here's the script that generates the thumbnail...
here's the code I actually include to display my gallery:
My problem is the image is not being displayed...
-The link works
-The Image name(s) are correctly displayed by Echo
-The website works..
-My host has all the latesr versions of the GD library
Any ideas?
I want to make it so I can create a gallery from a folder full of images... And add more by just dumping more into the folder.
here's the script that generates the thumbnail...
<?php # Constants define(IMAGE_BASE, '/var/www/html/mbailey/images'); define(MAX_WIDTH, 80); define(MAX_HEIGHT, 80); # Get image location $image_file = str_replace('..', '', $_SERVER['QUERY_STRING']); $image_path = IMAGE_BASE . "/$image_file"; # Load image $img = null; $ext = strtolower(end(explode('.', $image_path))); if ($ext == 'jpg' || $ext == 'jpeg') { $img = @imagecreatefromjpeg($image_path); } else if ($ext == 'png') { $img = @imagecreatefrompng($image_path); # Only if your version of GD includes GIF support } else if ($ext == 'gif') { $img = @imagecreatefrompng($image_path); } # If an image was successfully loaded, test the image for size if ($img) { # Get image size and scale ratio $width = imagesx($img); $height = imagesy($img); $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height); # If the image is larger than the max shrink it if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); # Create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); # Copy and resize old image into new image imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } } # Create error image if necessary if (!$img) { $img = imagecreate(MAX_WIDTH, MAX_HEIGHT); imagecolorallocate($img,0,0,0); $c = imagecolorallocate($img,70,70,70); imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2); imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2); } # Display the image header("Content-type: image/jpeg"); imagejpeg($img); ?>
here's the code I actually include to display my gallery:
<?php $fCount = 0; if ($handle = opendir('bignails')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (substr($file, strlen($file)-3, 3)=="jpg" ) { $fCount=$fCount+1; $fName[] = $file; } } } } closedir($handle); ?> <br/> <?php echo "Images in gallery: ",$fCount; ?> <table cellspacing = "2"> <?php for($i=0; $i<=$fCount-1; $i++){ $Name=$fName[$i]; ?> <?php echo $Name; ?> <td> <tr> <a href="bignails/<?php echo $Name; ?>"> <img src="tn_gen/thumb.php?bignails/<?php echo $Name; ?>"> </a> </tr> </td> <?php } ?> </table>
My problem is the image is not being displayed...
-The link works
-The Image name(s) are correctly displayed by Echo
-The website works..
-My host has all the latesr versions of the GD library
Any ideas?