You are here

function imagefield_focus_crop_effect in ImageField Focus 7

1 string reference to 'imagefield_focus_crop_effect'
imagefield_focus_image_effect_info in ./imagefield_focus.effects.inc
Implementation of hook_image_effect_info().

File

./imagefield_focus.effects.inc, line 171
Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

Code

function imagefield_focus_crop_effect(&$image, $data) {
  $files = file_load_multiple(array(), array(
    'uri' => $image->source,
  ));
  if (count($files)) {
    $file = reset($files);
    ($crop_rect = $file->crop_rect) && ($crop_rect = imagefield_focus_parse($crop_rect));
    ($focus_rect = $file->focus_rect) && ($focus_rect = imagefield_focus_parse($focus_rect));
    $target = $data['target'];
    if ($crop_rect && ($target == 'crop_rect only' || $target == 'crop_rect first' || $target == 'focus_rect first' && !$focus_rect)) {
      return image_crop_effect($image, $crop_rect);
    }
    if ($focus_rect && ($target == 'focus_rect only' || $target == 'focus_rect first' || $target == 'crop_rect first' && !$crop_rect)) {
      return image_crop_effect($image, $focus_rect);
    }
  }
  return TRUE;
}