Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

html_image
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Tue Jul 13, 2004 6:44 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jul 13, 2004 7:43 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Tue Jul 13, 2004 7:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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
Protected by Anti-Spam ACP