Changeset 25504 for trunk/include/derivative.inc.php
- Timestamp:
- Nov 17, 2013, 11:10:05 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/derivative.inc.php
r20516 r25504 193 193 194 194 /** 195 @return an associative array of derivative images with keys all standard derivative image types: 196 Disabled derivative types can be still found in the return mapped to an enabled derivative (e.g. the values are not 197 unique in the return array). This is useful for any plugin/theme to just use $deriv[IMG_XLARGE] even if the XLARGE is 198 disabled. 199 */ 195 * Return associative an array of all DerivativeImage for a specific image. 196 * Disabled derivative types can be still found in the return mapped to an 197 * enabled derivative (e.g. the values are not unique in the return array). 198 * This is useful for any plugin/theme to just use $deriv[IMG_XLARGE] even if 199 * the XLARGE is disabled. 200 * 201 * @param array|SrcImage $src_image array of info from db or SrcImage 202 * @return DerivativeImage[] 203 */ 200 204 static function get_all($src_image) 201 205 { 206 if (!is_object($src_image)) 207 { 208 $src_image = new SrcImage($src_image); 209 } 210 202 211 $ret = array(); 203 212 // build enabled types … … 207 216 $ret[$type] = $derivative; 208 217 } 209 // disabled types fqllbqck to enqbled types218 // disabled types, fallback to enabled types 210 219 foreach (ImageStdParams::get_undefined_type_map() as $type => $type2) 211 220 { … … 214 223 215 224 return $ret; 225 } 226 227 /** 228 * Returns an instance of DerivativeImage for a specific image and size. 229 * Disabled derivatives fallback to an enabled derivative. 230 * 231 * @param string $type 232 * @param array|SrcImage $src_image array of info from db or SrcImage 233 * @return DerivativeImage|null null if $type not found 234 */ 235 static function get_one($type, $src_image) 236 { 237 if (!is_object($src_image)) 238 { 239 $src_image = new SrcImage($src_image); 240 } 241 242 $defined = ImageStdParams::get_defined_type_map(); 243 if (isset($defined[$type])) 244 { 245 return new DerivativeImage($defined[$type], $src_image); 246 } 247 248 $undefined = ImageStdParams::get_undefined_type_map(); 249 if (isset($undefined[$type])) 250 { 251 return new DerivativeImage($defined[ $undefined[$type] ], $src_image); 252 } 253 254 return null; 216 255 } 217 256
Note: See TracChangeset
for help on using the changeset viewer.