Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

phpThumb plugin

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Italian
View previous topic :: View next topic  
Author Message
DjDrake
Smarty n00b


Joined: 12 Feb 2010
Posts: 2

PostPosted: Fri Feb 12, 2010 3:13 pm    Post subject: phpThumb plugin Reply with quote

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 .= "&amp;w=$v";
               $link .= "&amp;h=$v";
            ;
            break;
            
            default:
               $link .= "&amp;$k=$v";
               
            break;
         }
         
         
      }
   }   

      if(!isset($params['zc'])){
         $link .= "&amp;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
View user's profile Send private message
cacofony
Smarty n00b


Joined: 27 Oct 2014
Posts: 1

PostPosted: Mon Oct 27, 2014 1:22 pm    Post subject: phpThumb with security enabled Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Italian All times are GMT
Page 1 of 1

 
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