From 18036a70fcee8e372b6b8d98fbe8a61a3685798f Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 2 Feb 2012 20:59:41 +0000 Subject: feature 2548 multisize - custom sizes restricted to those requested by theme/plugin code refacto git-svn-id: http://piwigo.org/svn/trunk@13021 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/template.class.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'include/template.class.php') diff --git a/include/template.class.php b/include/template.class.php index 9e06b5d2d..5596c2ec9 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -559,31 +559,33 @@ class Template { !empty($params['width']) or fatal_error('define_derviative missing width'); !empty($params['height']) or fatal_error('define_derviative missing height'); - $derivative = new DerivativeParams( SizingParams::classic( intval($params['width']), intval($params['height'])) ); + $w = intval($params['width']); + $h = intval($params['height']); + $crop = 0; + $minw=null; + $minh=null; + if (isset($params['crop'])) { if (is_bool($params['crop'])) { - $derivative->sizing->max_crop = $params['crop'] ? 1:0; + $crop = $params['crop'] ? 1:0; } else { - $derivative->sizing->max_crop = round($params['crop']/100, 2); + $crop = round($params['crop']/100, 2); } - if ($derivative->sizing->max_crop) + if ($crop) { - $minw = empty($params['min_width']) ? $derivative->max_width() : intval($params['min_width']); - $minw <= $derivative->max_width() or fatal_error('define_derviative invalid min_width'); - $minh = empty($params['min_height']) ? $derivative->max_height() : intval($params['min_height']); - $minh <= $derivative->max_height() or fatal_error('define_derviative invalid min_height'); - - $derivative->sizing->min_size = array($minw, $minh); + $minw = empty($params['min_width']) ? $w : intval($params['min_width']); + $minw <= $w or fatal_error('define_derviative invalid min_width'); + $minh = empty($params['min_height']) ? $h : intval($params['min_height']); + $minh <= $h or fatal_error('define_derviative invalid min_height'); } } - ImageStdParams::apply_global($derivative); - $smarty->assign( $params['name'], $derivative); + $smarty->assign( $params['name'], ImageStdParams::get_custom($w, $h, $crop, $minw, $minh) ); } /** -- cgit v1.2.3