You are here

function mediafield_field_delete in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 modules/mediafield/mediafield.module \mediafield_field_delete()
  2. 7.2 modules/mediafield/mediafield.module \mediafield_field_delete()

Implements hook_field_delete().

File

modules/mediafield/mediafield.module, line 292
Provide a "Multimedia asset" field.

Code

function mediafield_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);

  // Delete all file usages within this entity.
  foreach ($items as $delta => $item) {
    $file = (object) $item;
    file_usage_delete($file, 'mediafield', $entity_type, $id, 0);
  }
}