You are here

function _manualcrop_get_auto_reuse_style_name in Manual Crop 7

Get the image style name that should be used when processing the auto reuse effect.

Parameters

$file: Path to an image file.

$data: Auto reuse effect data.

Return value

Image style name that can be reused or FALSE if no crop selection was found.

1 call to _manualcrop_get_auto_reuse_style_name()
manualcrop_auto_reuse_effect in ./manualcrop.module
Image effect callback; Search for a Manual Crop effect with a crop selection and reuse it.

File

./manualcrop.helpers.inc, line 828
Helper functions for the Manual Crop module.

Code

function _manualcrop_get_auto_reuse_style_name($file, $data) {

  // Get the crop selections.
  $crop = manualcrop_load_crop_selection($file);
  if ($crop) {
    if (!empty($data['style_priority'])) {

      // Get a list of existing crop styles (keys) ordered by priority.
      $styles = array_flip($data['style_priority']) + $crop;
      $crop = array_intersect_key($styles, $crop);
    }

    // Return the first crop selection style name.
    reset($crop);
    return key($crop);
  }
  return FALSE;
}