aboutsummaryrefslogtreecommitdiffstats
path: root/include/derivative.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-05-04 04:29:44 +0000
committerrvelices <rv-github@modusoptimus.com>2012-05-04 04:29:44 +0000
commit7d621ae61b733ca65acfda626004be03936e7596 (patch)
tree4cff1457f23b7e0808dd8cf9f712fd629650053e /include/derivative.inc.php
parentd419f4223e4263860bbf364e403ed028e42e5b39 (diff)
multi size - don't fail if image metadata was not previously synced
git-svn-id: http://piwigo.org/svn/trunk@14735 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/derivative.inc.php')
-rw-r--r--include/derivative.inc.php48
1 files changed, 35 insertions, 13 deletions
diff --git a/include/derivative.inc.php b/include/derivative.inc.php
index f565364f3..3d5be32d5 100644
--- a/include/derivative.inc.php
+++ b/include/derivative.inc.php
@@ -23,6 +23,7 @@ final class SrcImage
{
const IS_ORIGINAL = 0x01;
const IS_MIMETYPE = 0x02;
+ const DIM_NOT_GIVEN = 0x04;
public $id;
public $rel_path;
@@ -51,24 +52,36 @@ final class SrcImage
$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);
+ if ( ($size=@getimagesize(PHPWG_ROOT_PATH.$this->rel_path)) === false)
+ {
+ $this->rel_path = get_themeconf('mime_icon_dir').'unknown.png';
+ $size = getimagesize(PHPWG_ROOT_PATH.$this->rel_path);
+ }
+ $this->size = array($size[0],$size[1]);
}
- if (!$this->size && isset($infos['width']) && isset($infos['height']))
+ if (!$this->size)
{
- $width = $infos['width'];
- $height = $infos['height'];
+ if (isset($infos['width']) && isset($infos['height']))
+ {
+ $width = $infos['width'];
+ $height = $infos['height'];
- $this->rotation = intval($infos['rotation']) % 4;
- // 1 or 5 => 90 clockwise
- // 3 or 7 => 270 clockwise
- if ($this->rotation % 2)
+ $this->rotation = intval($infos['rotation']) % 4;
+ // 1 or 5 => 90 clockwise
+ // 3 or 7 => 270 clockwise
+ if ($this->rotation % 2)
+ {
+ $width = $infos['height'];
+ $height = $infos['width'];
+ }
+
+ $this->size = array($width, $height);
+ }
+ elseif (!array_key_exists('width', $infos))
{
- $width = $infos['height'];
- $height = $infos['width'];
+ $this->flags |= self::DIM_NOT_GIVEN;
}
-
- $this->size = array($width, $height);
}
}
@@ -105,7 +118,16 @@ final class SrcImage
function get_size()
{
if ($this->size == null)
- not_implemented(); // get size from file
+ {
+ if ($this->flags & self::DIM_NOT_GIVEN)
+ fatal_error('SrcImage dimensions required but not provided');
+ // probably not metadata synced
+ if ( ($size = getimagesize( $this->get_path() )) !== false)
+ {
+ $this->size = array($size[0],$size[1]);
+ pwg_query('UPDATE '.IMAGES_TABLE.' SET width='.$size[0].', height='.$size[1].' WHERE id='.$this->id);
+ }
+ }
return $this->size;
}
}