Changeset 12954 for trunk/include/derivative.inc.php
- Timestamp:
- Jan 24, 2012, 8:24:47 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/derivative.inc.php
r12908 r12954 25 25 const IS_MIMETYPE = 0x02; 26 26 27 public $id; 27 28 public $rel_path; 28 29 … … 34 35 { 35 36 global $conf; 36 37 38 $this->id = $infos['id']; 37 39 $ext = get_extension($infos['path']); 38 40 if (in_array($ext, $conf['picture_ext'])) … … 77 79 function get_url() 78 80 { 79 return get_root_url().$this->rel_path;81 return embellish_url(get_root_url().$this->rel_path); 80 82 } 81 83 … … 97 99 final class DerivativeImage 98 100 { 99 const SAME_AS_SRC = 0x10;100 101 101 public $src_image; 102 102 103 private $flags = 0;104 103 private $params; 105 104 private $rel_path, $rel_url; … … 117 116 } 118 117 119 self::build($src_image, $this->params, $this->rel_path, $this->rel_url , $this->flags);118 self::build($src_image, $this->params, $this->rel_path, $this->rel_url); 120 119 } 121 120 … … 130 129 $params = is_string($type) ? ImageStdParams::get_by_type($type) : $type; 131 130 self::build($src_image, $params, $rel_path, $rel_url); 132 return get_root_url().$rel_url; 131 if ($params == null) 132 { 133 return $src_image->get_url(); 134 } 135 return embellish_url( 136 trigger_event('get_derivative_url', 137 get_root_url().$rel_url, 138 $params, $src_image, $rel_url 139 ) ); 133 140 } 134 141 … … 149 156 } 150 157 151 private static function build($src, &$params, &$rel_path, &$rel_url , &$flags = null)158 private static function build($src, &$params, &$rel_path, &$rel_url) 152 159 { 153 160 if ( $src->has_size() && $params->is_identity( $src->get_size() ) ) 154 161 { 155 162 // todo - what if we have a watermark maybe return a smaller size? 156 $flags |= self::SAME_AS_SRC;157 163 $params = null; 158 164 $rel_path = $rel_url = $src->rel_path; … … 221 227 function get_url() 222 228 { 223 return get_root_url().$this->rel_url; 229 if ($this->params == null) 230 { 231 return $this->src_image->get_url(); 232 } 233 return embellish_url( 234 trigger_event('get_derivative_url', 235 get_root_url().$this->rel_url, 236 $this->params, $this->src_image, $this->rel_url 237 ) ); 224 238 } 225 239 226 240 function same_as_source() 227 241 { 228 return $this-> flags & self::SAME_AS_SRC;242 return $this->params == null; 229 243 } 230 244 … … 232 246 function get_type() 233 247 { 234 if ($this-> flags & self::SAME_AS_SRC)248 if ($this->params == null) 235 249 return 'original'; 236 250 return $this->params->type; … … 240 254 function get_size() 241 255 { 242 if ($this-> flags & self::SAME_AS_SRC)256 if ($this->params == null) 243 257 { 244 258 return $this->src_image->get_size();
Note: See TracChangeset
for help on using the changeset viewer.