|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Tue Jul 13, 2004 6:44 am Post subject: |
|
|
messju wrote: | one aspect is missing here. if you don't pass a width to html_image then the width is determined with GetImageSize(). with a modifier like above you cannot say "use the default imagesize but only up to 200px".
just my 2c. |
Sorry but I don`t understand!
My correction:
[php:1:7148ea6cbe]
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty max modifier plugin
*
* Type: modifier<br>
* Name: max<br>
* Purpose: correct a given number to the max if needed
*
* @param integer
* @param integer
* @return integer
*/
function smarty_modifier_max( $number, $max)
{
if ( !is_numeric( $number)) {
trigger_error( "Unexpected parametertype for \$number '$number'! Excpecting numeric!", E_USER_NOTICE);
return;
} elseif ( !is_numeric( $max)) {
trigger_error( "Unexpected parametertype for \$max '$max'! Excpecting numeric!", E_USER_NOTICE);
return;
} else {
if( $number > $max) return $max;
return $number;
}
}
?> [/php:1:7148ea6cbe] |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jul 13, 2004 7:43 am Post subject: |
|
|
I just meant:
{html_image file="foo.jpg"}
for convinience smarty makes it something like:
<img src="foo.jpg" width=180 height=100 ...>
it reads the size of foo.jpg from the jpegfile and creates a width- abd height-attribute.
you cannot combine that with your max-modifier. |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Tue Jul 13, 2004 7:56 am Post subject: |
|
|
messju wrote: | I just meant:
{html_image file="foo.jpg"}
for convinience smarty makes it something like:
<img src="foo.jpg" width=180 height=100 ...>
it reads the size of foo.jpg from the jpegfile and creates a width- abd height-attribute.
you cannot combine that with your max-modifier. |
thats correct..
i read the filesizes from the image manually.
is there a easier way to do it? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|