You are here

function imagefield_crop_field_delete_revision in Imagefield Crop 7.2

Same name and namespace in other branches
  1. 7.3 imagefield_crop.module \imagefield_crop_field_delete_revision()

Implements hook_field_delete_revision().

File

./imagefield_crop.module, line 391
Functionality and Drupal hook implementations for the Imagefield Crop module.

Code

function imagefield_crop_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  foreach ($items as $delta => $item) {

    // Decrement the file usage count by 1 and delete the file if possible.
    if (file_field_delete_file($item, $field, $entity_type, $id)) {
      $orig_file = _imagefield_crop_file_to_crop($item['fid']);
      if ($orig_file && $orig_file->fid != $item['fid']) {
        file_usage_delete($orig_file, 'imagefield_crop', 'file', $item['fid']);
        file_delete($orig_file);
      }
      $items[$delta] = NULL;
    }
  }
}