You are here

function imagecrop_effect in Image javascript crop 7

Image effect callback: Crop the image based on the javascript selected crop.

Parameters

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

$data An array of settings from the user for cropping the image.:

Return value

TRUE on success. FALSE on failure to crop the image.

2 string references to 'imagecrop_effect'
imagecrop_image_effect_info in includes/imagecrop.effects.inc
Implements hook_image_effect_info().
imagecrop_image_style_delete in ./imagecrop.module
Implements hook_image_style_delete().

File

includes/imagecrop.effects.inc, line 43
Registry for the image style effects from imagecrop.

Code

function imagecrop_effect(&$image, $data) {
  try {
    $imagecrop = new ImageCrop();
    $imagecrop
      ->loadFile($image->source, FALSE);

    // if a global presetid is been set, it meens the image is generated from the imagecrop module
    if (isset($GLOBALS['imagecrop_style'])) {
      $style_name = $GLOBALS['imagecrop_style'];
    }
    else {
      $style_name = imagecrop_get_style_name_from_url();
    }
    $imagecrop
      ->setImageStyle($style_name);
    $imagecrop
      ->loadCropSettings();
    $imagecrop
      ->applyCrop($image);
  } catch (Exception $e) {
    drupal_set_message(t('Unable to crop image.'), 'error');
    watchdog_exception('imagecrop', $e);
    return FALSE;
  }
  return TRUE;
}