function galleryformatter_getimage_dimensions in Gallery formatter 6
Same name and namespace in other branches
- 7 galleryformatter.module \galleryformatter_getimage_dimensions()
Helper function to get dimensions of an image
Return value
array An array key => value pairs width => value and height => value, not including px
1 call to galleryformatter_getimage_dimensions()
- template_preprocess_galleryformatter_formatter_galleryformatter_default in includes/
galleryformatter.theme.inc - Preprocess function for galleryformatter.tpl.php
File
- ./
galleryformatter.module, line 211
Code
function galleryformatter_getimage_dimensions($presetname, $image_path) {
// generate the imagecache preset image path
$transformed_path = imagecache_create_path($presetname, $image_path);
// grab the preset itself
$preset = imagecache_preset_by_name($presetname);
// get the default presets names provided by galleryformatter
foreach (galleryformatter_imagecache_default_presets() as $key => $value) {
$default_presets[] = $value['presetname'];
}
// if using the default preset no need to get image info
$default_preset = in_array($preset['presetname'], $default_presets);
if ($preset['storage'] == 1 && $default_preset) {
$ret['height'] = $preset['actions'][0]['data']['height'];
$ret['width'] = $preset['actions'][0]['data']['width'];
}
elseif (file_exists($transformed_path) || imagecache_build_derivative($preset['actions'], $image_path, $transformed_path)) {
// grab the image information
$image = image_get_info($transformed_path);
$ret['height'] = $image['height'];
$ret['width'] = $image['width'];
}
return $ret;
}