RE: [SMARTY-DEV] html_image width and height
| From: | Thomas Schulz | Date: | Fri, 07 Mar 2003 00:07:27 +0000 |
| Subject: | RE: [SMARTY-DEV] html_image width and height | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-919@lists.php.net to get a copy of this message | ||
Monte Ohrt schrieb in php.smarty.dev:
> Actually it can be a file or path/file:
>
> {image name="path/to/foo.jpg"}
>
> so change to file? any other votes? :-)
YES, I would like to see my resize-feature in html_image :-)
This is useful when generating a printer friendly version of a page.
{html_image name="images/logo4print.gif" dpi="300"}
It recalculate the detected size of an given image so that it become a
finer resolution in printed output.
Take a look:
===================================================================
RCS file: /repository/smarty/libs/plugins/function.html_image.php,v
retrieving revision 1.7
diff -u -r1.7 function.html_image.php
--- function.html_image.php 6 Mar 2003 21:39:16 -0000 1.7
+++ function.html_image.php 7 Mar 2003 00:06:27 -0000
@@ -30,6 +30,7 @@
$border = 0;
$height = '';
$width = '';
+ $dpi_default = 96;
$extra = '';
$prefix = '';
$suffix = '';
@@ -50,6 +51,9 @@
case 'width':
$width = $_val;
break;
+ case 'dpi':
+ $dpi = $_val;
+ break;
case 'link':
$prefix = '<a href="' . $link . '">';
$suffix = '</a>';
@@ -91,6 +95,11 @@
$height = $_image_data[1];
}
+ if(isset($params['dpi'])) {
+ $resize = $dpi_default/$dpi;
+ $width = round($width * $resize);
+ $height = round($height * $resize);
+ }
}
return $prefix . '<img src="'.$name.'"
border="'.$border.'"
width="'.$width.'"
height="'.$height.'"'.$extra.'>' . $suffix;