Show
Ignore:
Timestamp:
02/02/12 21:59:41 (16 months ago)
Author:
rvelices
Message:

feature 2548 multisize - custom sizes restricted to those requested by theme/plugin
code refacto

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r12955 r13021  
    560560    !empty($params['height']) or fatal_error('define_derviative missing height'); 
    561561 
    562     $derivative = new DerivativeParams( SizingParams::classic( intval($params['width']), intval($params['height'])) ); 
     562    $w = intval($params['width']); 
     563    $h = intval($params['height']); 
     564    $crop = 0; 
     565    $minw=null; 
     566    $minh=null; 
     567     
    563568    if (isset($params['crop'])) 
    564569    { 
    565570      if (is_bool($params['crop'])) 
    566571      { 
    567         $derivative->sizing->max_crop = $params['crop'] ? 1:0; 
     572        $crop = $params['crop'] ? 1:0; 
    568573      } 
    569574      else 
    570575      { 
    571         $derivative->sizing->max_crop = round($params['crop']/100, 2); 
    572       } 
    573  
    574       if ($derivative->sizing->max_crop) 
    575       { 
    576         $minw = empty($params['min_width']) ? $derivative->max_width() : intval($params['min_width']); 
    577         $minw <= $derivative->max_width() or fatal_error('define_derviative invalid min_width'); 
    578         $minh = empty($params['min_height']) ? $derivative->max_height() : intval($params['min_height']); 
    579         $minh <= $derivative->max_height() or fatal_error('define_derviative invalid min_height'); 
    580  
    581         $derivative->sizing->min_size = array($minw, $minh); 
    582       } 
    583     } 
    584  
    585     ImageStdParams::apply_global($derivative); 
    586     $smarty->assign( $params['name'], $derivative); 
     576        $crop = round($params['crop']/100, 2); 
     577      } 
     578 
     579      if ($crop) 
     580      { 
     581        $minw = empty($params['min_width']) ? $w : intval($params['min_width']); 
     582        $minw <= $w or fatal_error('define_derviative invalid min_width'); 
     583        $minh = empty($params['min_height']) ? $h : intval($params['min_height']); 
     584        $minh <= $h or fatal_error('define_derviative invalid min_height'); 
     585      } 
     586    } 
     587 
     588    $smarty->assign( $params['name'], ImageStdParams::get_custom($w, $h, $crop, $minw, $minh) ); 
    587589  } 
    588590