Page 1 of 1

Echoing a link to a thumbnail

Posted: Tue Nov 18, 2008 1:52 pm
by Theory?
So this is very weak implementation code just to really test my design in it's current state. I'm at the point where I'd like to see if and how I can get the thumbnail to act as a link to the full size image. Unfortunately, my code obviously isn't working. I know it doesn't make sense at all since the imagejpeg() function returns a boolean value and not any sort of name or html resource, but you can see where I was coming from, I'm sure. I'm just curious as to how this is carried out.

Code: Select all

<?php
 
require_once 'Image.php';
require_once 'SquareCropThumb.php';
 
$img = new Image('images/test1.jpg');
$img->makeThumb(new SquareCropThumb());
$thumb = $img->getThumb();
 
header('Content-Type: image/jpeg');
 
echo '<a href="images/test1.jpg">' . imagejpeg($thumb, NULL, 100) . '</a>';
 
imagedestroy($thumb);
 
?>

Re: Echoing a link to a thumbnail

Posted: Fri Nov 21, 2008 5:05 am
by novice4eva
Lets say this is show_image.php file:

Code: Select all

 
<?php
 
require_once 'Image.php';
require_once 'SquareCropThumb.php';
 
$img = new Image('images/test1.jpg');
$img->makeThumb(new SquareCropThumb());
$thumb = $img->getThumb();
 
header('Content-Type: image/jpeg');
 
imagejpeg($thumb, NULL, 100);
 
imagedestroy($thumb);
 
?>
 
Then you would do:

Code: Select all

 
echo '<a href="images/test1.jpg"><img src="show_image.php" border="0"></a>'