Html_image suggestion
| From: | Andreas Goetz | Date: | Sat, 10 Jan 2004 17:36:25 +0000 |
| Subject: | Html_image suggestion | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10805@lists.php.net to get a copy of this message | ||
I do currently have the problem that I want to display images in a list,
with correct aspect/ration, but not bigger than a certain size to NOT screw
up the design. If of general interest, I'd suggest the following addition to
html_image:
if($params['max_width'] && $params['max_height'] &&
$width &&
$height) {
# nothing should be 0 now
if ($width > $params['max_width']) {
$height = round($height * $params['max_width'] /
$width);
$width = $params['max_width'];
} elseif ($height > $params['max_height']) {
$width = round($width * $params['max_height'] /
$height);
$height = $params['max_height'];
}
}
Also documentation describes usage as {image... Which must be
{html_image.... This is quite confusing for the beginner :)
Thanks for the excellent smarty,
Andreas Goetz
cpuidle@gmx.de
http://www.cpuidle.de