You are here

function manualcrop_reuse_effect in Manual Crop 7

Image effect callback; Reuse the crop effect of another image style.

Parameters

$image: An image object returned by image_load().

$data: An array of settings, needed to perform the reuse effect, with the following items:

  • "reuse_crop_style": Name of the image style to reuse the crop effect of.

Return value

TRUE on success, FALSE when the crop effect couldn't be reused.

See also

image_crop_effect()

1 call to manualcrop_reuse_effect()
manualcrop_crop_effect in ./manualcrop.module
Image effect callback; Crop an image resource.
1 string reference to 'manualcrop_reuse_effect'
manualcrop_image_effect_info in ./manualcrop.module
Implements hook_image_effect_info().

File

./manualcrop.module, line 902

Code

function manualcrop_reuse_effect(&$image, $data) {
  if (empty($data['reuse_crop_style'])) {
    return FALSE;
  }

  // Load the style to reuse.
  $style = image_style_load($data['reuse_crop_style']);
  if (empty($data['apply_all_effects'])) {

    // Apply only the crop effect.
    $effect = reset($style['effects']);
    return image_effect_apply($image, $effect);
  }
  else {

    // Apply all effects.
    foreach ($style['effects'] as $effect) {
      if (!image_effect_apply($image, $effect)) {
        return FALSE;
      }
    }
    return TRUE;
  }
}