aboutsummaryrefslogtreecommitdiffstats
path: root/include/derivative_std_params.inc.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/derivative_std_params.inc.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/derivative_std_params.inc.php')
-rw-r--r--include/derivative_std_params.inc.php31
1 files changed, 28 insertions, 3 deletions
diff --git a/include/derivative_std_params.inc.php b/include/derivative_std_params.inc.php
index 9377b4c67..773866dec 100644
--- a/include/derivative_std_params.inc.php
+++ b/include/derivative_std_params.inc.php
@@ -46,6 +46,7 @@ final class ImageStdParams
private static $type_map = array();
private static $undefined_type_map = array();
private static $watermark;
+ public static $custom = array();
static function get_all_types()
{
@@ -71,6 +72,22 @@ final class ImageStdParams
{
return self::$all_type_map[$type];
}
+
+ static function get_custom($w, $h, $crop=0, $minw=null, $minh=null)
+ {
+ $params = new DerivativeParams( new SizingParams( array($w,$h), $crop, array($minw,$minh)) );
+ self::apply_global($params);
+
+ $key = array();
+ $params->add_url_tokens($key);
+ $key = implode('_',$key);
+ if ( @self::$custom[$key] < time() - 24*3600)
+ {
+ self::$custom[$key] = time();
+ self::save();
+ }
+ return $params;
+ }
static function get_watermark()
{
@@ -103,6 +120,8 @@ final class ImageStdParams
self::$type_map = $arr['d'];
self::$watermark = @$arr['w'];
if (!self::$watermark) self::$watermark = new WatermarkParams();
+ self::$custom = @$arr['c'];
+ if (!self::$custom) self::$custom = array();
}
else
{
@@ -118,16 +137,22 @@ final class ImageStdParams
static function set_and_save($map)
{
- global $conf;
self::$type_map = $map;
+ self::save();
+ self::build_maps();
+ }
+
+ static function save()
+ {
+ global $conf;
$ser = serialize( array(
'd' => self::$type_map,
'w' => self::$watermark,
+ 'c' => self::$custom,
) );
conf_update_param('derivatives', addslashes($ser) );
file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'derivatives.dat', $ser);
- self::build_maps();
}
private static function make_default()
@@ -142,7 +167,7 @@ final class ImageStdParams
self::$type_map[IMG_XXLARGE] = new DerivativeParams( SizingParams::classic(1200,900) );
}
- public static function apply_global($params)
+ static function apply_global($params)
{
if (!empty(self::$watermark->file) &&
(self::$watermark->min_size[0]<=$params->sizing->ideal_size[0]