You are here

function media_wysiwyg_entity_delete in D7 Media 7.4

Same name and namespace in other branches
  1. 7.2 modules/media_wysiwyg/includes/media_wysiwyg.file_usage.inc \media_wysiwyg_entity_delete()
  2. 7.3 modules/media_wysiwyg/includes/media_wysiwyg.file_usage.inc \media_wysiwyg_entity_delete()

Implements hook_entity_delete().

File

modules/media_wysiwyg/includes/media_wysiwyg.file_usage.inc, line 144
Functions related to the tracking the file usage of embedded media.

Code

function media_wysiwyg_entity_delete($entity, $type) {
  $info = entity_get_info($type);

  // Try to delete the related used files on the entity only if it's fieldable,
  // because non-fieldable entities may have non-numeric ID, which could cause
  // to fail in case of postgres.
  if ($info['fieldable']) {
    list($entity_id) = entity_extract_ids($type, $entity);
    db_delete('file_usage')
      ->condition('module', 'media')
      ->condition('type', $type)
      ->condition('id', $entity_id)
      ->execute();
  }
}