You are here

function angular_media_process_crop in CKEditor Widgets 7

Performs a crop on a file

1 call to angular_media_process_crop()
angular_media_callback_file in ./angular_media.module
Callback to retrieve (GET) or save (POST) updates.

File

./angular_media.module, line 405
Implementation of angular_media.module.

Code

function angular_media_process_crop($src, $crop) {

  // If we're not overwriting, create a copy
  if (!$crop['overwrite']) {
    if ($orig_uri = file_unmanaged_copy($src->uri, $src->uri)) {
      $filename = $src->filename;
      $filename = t('Crop !filename', array(
        '!filename' => $filename,
      ));
      $orig = clone $src;
      $orig->fid = 0;
      $orig->uri = $orig_uri;
      $orig->filename = $filename;
      $orig->status = 1;
      $orig = file_save($orig);
      file_usage_add($orig, 'angular_media', 'file', $src->fid);
      $src = $orig;
    }
    else {
      return false;
    }
  }
  $scale = NULL;
  $src_uri = drupal_realpath($src->uri);
  if (_angular_media_crop_resize($src_uri, $crop, $scale, $src_uri)) {

    // Remove cached versions of the cropped image.
    image_path_flush($src_uri);
  }
  return $src;
}