thanks - here's the code pretty much
resize_image.php consists of, as the name hints, a resizing script that i have been passing variables to with an appended string 'resize_image.php?image=pictures/434.jpg':
PHP Code:
if (!$max_width)
$max_width = 120;
if (!$max_height)
$max_height = 120;
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJPEG($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
header("Content-type: image/jpeg");
ImageJPEG($dst);
ImageDestroy($src);
ImageDestroy($dst);
so my trouble is how to append it dynamically within the smarty template: I'd like to do something like:
<img src = resize_image.php?image={$main.picture}>
but to include php like that in the smarty template you need to bracket it with either {include_php} or {php} the problem is then that if you're calling what's inside those brackets php, {$main.picture} can no longer be processed as a template variable.
I've tried to get the thing to compile on the php page and output <img src = resize_image.php?image={$main.picture}> with the picture inserted dynamically into the template file - doesn't seem to work. Don't know if there's a way of doing this but I'd be massively thankful for any kind of solution.
thanks!
Bookmarks