aboutsummaryrefslogtreecommitdiffstats
path: root/include/derivative.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2011-12-27 20:26:49 +0000
committerrvelices <rv-github@modusoptimus.com>2011-12-27 20:26:49 +0000
commite42f791f52c502c00d095d6bf9aa3e3989423e98 (patch)
tree965cbd888b954302e4652fefa7d56ef2e074eb66 /include/derivative.inc.php
parent753f58d6a966a1051dcd62a3eeab8fc18798bcac (diff)
feature 2541 multisize
- nicer presentation on picture.php - added a maintenance purge derivatives action git-svn-id: http://piwigo.org/svn/trunk@12797 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/derivative.inc.php')
-rw-r--r--include/derivative.inc.php45
1 files changed, 40 insertions, 5 deletions
diff --git a/include/derivative.inc.php b/include/derivative.inc.php
index 11f1ebb76..c22e27573 100644
--- a/include/derivative.inc.php
+++ b/include/derivative.inc.php
@@ -21,10 +21,14 @@
final class SrcImage
{
+ const IS_ORIGINAL = 0x01;
+ const IS_MIMETYPE = 0x02;
+
public $rel_path;
-
+
public $coi=null;
private $size=null;
+ private $flags=0;
function __construct($infos)
{
@@ -34,6 +38,7 @@ final class SrcImage
if (in_array($ext, $conf['picture_ext']))
{
$this->rel_path = $infos['path'];
+ $this->flags |= self::IS_ORIGINAL;
}
elseif (!empty($infos['representative_ext']))
{
@@ -44,16 +49,39 @@ final class SrcImage
}
else
{
- $this->rel_path = get_themeconf('mime_icon_dir').strtolower($ext).'.png';
+ $ext = strtolower($ext);
+ $this->rel_path = trigger_event('get_mimetype_location', get_themeconf('mime_icon_dir').$ext.'.png', $ext );
+ $this->flags |= self::IS_MIMETYPE;
+ $this->size = @getimagesize(PHPWG_ROOT_PATH.$this->rel_path);
}
$this->coi = @$infos['coi'];
- if (isset($infos['width']) && isset($infos['height']))
+ if (!$this->size && isset($infos['width']) && isset($infos['height']))
{
$this->size = array($infos['width'], $infos['height']);
}
}
+ function is_original()
+ {
+ return $this->flags & self::IS_ORIGINAL;
+ }
+
+ function is_mimetype()
+ {
+ return $this->flags & self::IS_MIMETYPE;
+ }
+
+ function get_path()
+ {
+ return PHPWG_ROOT_PATH.$this->rel_path;
+ }
+
+ function get_url()
+ {
+ return get_root_url().$this->rel_path;
+ }
+
function has_size()
{
return $this->size != null;
@@ -126,7 +154,7 @@ final class DerivativeImage
{
$ret[$type] = $ret[$type2];
}
-
+
return $ret;
}
@@ -144,7 +172,7 @@ final class DerivativeImage
$tokens=array();
$tokens[] = substr($params->type,0,2);
- if (!empty($src->coi))
+ if ($params->sizing->max_crop != 0 and !empty($src->coi))
{
$tokens[] = 'ci'.$src->coi;
}
@@ -206,6 +234,13 @@ final class DerivativeImage
}
+ function get_type()
+ {
+ if ($this->flags & self::SAME_AS_SRC)
+ return 'original';
+ return $this->params->type;
+ }
+
/* returns the size of the derivative image*/
function get_size()
{