aboutsummaryrefslogtreecommitdiffstats
path: root/include/template.class.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-02-02 20:59:41 +0000
committerrvelices <rv-github@modusoptimus.com>2012-02-02 20:59:41 +0000
commit18036a70fcee8e372b6b8d98fbe8a61a3685798f (patch)
tree5f81c65b42dd992c878ef49ea94da23673fbd808 /include/template.class.php
parenta68826cbb3ad9b09edc6c13a63923b4e827f918f (diff)
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
Diffstat (limited to 'include/template.class.php')
-rw-r--r--include/template.class.php26
1 files changed, 14 insertions, 12 deletions
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) );
}
/**