|
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 |
DjDrake Smarty n00b
Joined: 12 Feb 2010 Posts: 2
|
Posted: Fri Feb 12, 2010 3:13 pm Post subject: phpThumb plugin |
|
|
Non so quanto vi possa essere utile ma ho elaborato un piccolo plugin per velocizzare l'uso di phpThmb (classe php per generare thumb).
per utilizzarlo basta salvare il file nella cartella plugin di smarty.
Salvare il file con questa dicitura "function.phpthumb.php".
Il codice č da migliorare perņ penso che possa essere una buona base per chi non volesse perdere tempo.
Code: |
<?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
*/
function smarty_function_phpthumb($params, &$smarty)
{
if (empty($params['path'])) {
$smarty->trigger_error("assign: variabile 'path' mancante");
return;
}
$phpthumb = "phpThumb/phpThumb.php?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";
}
return $link;
}
?>
|
per utilizzare la funzione basta digitare Code: | {phpthumb path='path/to/image' attr1=$attr1 atrr2=$attr2 ...attrN=$attrN} |
esempio : Code: | {phpthumb path='images/immagine.jpg' w=100 h=50 zc='l'} |
P.S. ho inserito un tag standard per creare thumb quadrate senza dover specificare base e altezza della stessa dimensione.
Il tag in questione č 'wh'.
Esempio Code: | {phpthumb path='images/immagine.jpg' wh=100} |
|
|
Back to top |
|
cacofony Smarty n00b
Joined: 27 Oct 2014 Posts: 1
|
Posted: Mon Oct 27, 2014 1:22 pm Post subject: phpThumb with security enabled |
|
|
Modified to use phpThumbURL
Code: |
<?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;
}
|
|
|
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
|