You are here

function _asset_imagecache_get_size in Asset 6

Same name in this branch
  1. 6 modules/asset_imagecache.inc \_asset_imagecache_get_size()
  2. 6 inc/modules/asset_imagecache.inc \_asset_imagecache_get_size()
Same name and namespace in other branches
  1. 5 modules/asset_imagecache.inc \_asset_imagecache_get_size()

File

inc/modules/asset_imagecache.inc, line 66

Code

function _asset_imagecache_get_size($name, $path) {
  $preset = imagecache_preset_by_name($name);
  $actions = imagecache_preset_actions($preset);
  $action = array_pop($actions);
  $rule = $action['data'];
  if (!$rule['height'] || !$rule['width']) {
    $info = image_get_info(file_create_path($path));
    if (!$rule['height']) {
      $aspect = $rule['width'] / $info['width'];
      $rule['height'] = $info['height'] * $aspect;
    }
    elseif (!$rule['width']) {
      $aspect = $rule['height'] / $info['height'];
      $rule['width'] = $info['width'] * $aspect;
    }
  }
  return $rule;
}