Upgrading phpThumb has high security enabled by default. The preferred method for URL generation is then phpThumbURL. We found an existing function to use phpThumb as a smarty function but it was not designed to use phpThumbURL, so we modified it.
<!–more–>
<pre><?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*
* Smarty {phpthumb} function plugin
*
* Type: function<br>
* Name: phpthumb<br>
* Purpose: riscrittura di un link integrando la libreria phpthumb<br>
* @author Somma Michele draco88[at]hotmail.it
* @param array
* @param Smarty
* @return string
*/
require_once(‘phpthumb/phpThumb.config.php’);
function smarty_function_phpthumb($params, &$smarty)
{
if (empty($params[‘path’])) {
$smarty->trigger_error(“assign: variabile ‘path’ mancante”);
return;
}
$phpthumb = “src=”;
$link= $phpthumb.$params[‘path’];
foreach ($params as $k=>$v){
if ($k!=”path”) {
/*eccezzioni*/
switch ($k) {
case “wh”:
$link .= “&w=$v”;
$link .= “&h=$v”;
;
break;
default:
$link .= “&$k=$v”;
break;
}
}
}
if(!isset($params[‘zc’])){
$link .= “&zc=l”;
}
$link = htmlspecialchars(phpThumbURL($link, ‘phpthumb/phpThumb.php’));
return $link;
}</pre>
Usage
<pre>{phpthumb path=’path/to/image’ attr1=$attr1 atrr2=$attr2 …attrN=$attrN}</pre>
Example
<pre>{phpthumb path=’images/image.jpg’ w=100 h=50}</pre>
Thanks to the original author Somma Michele http://www.smarty.net/forums/viewtopic.php?t=16841