function media_gallery_file_delete in Media Gallery 7.2
Implements hook_file_delete().
When an image is deleted, remove it from media_gallery nodes first.
File
- ./
media_gallery.module, line 265
Code
function media_gallery_file_delete($file) {
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'node')
->fieldCondition('media_gallery_file', 'fid', $file->fid, '=')
->execute();
if (isset($result['node'])) {
$nids = array_keys($result['node']);
$nodes = entity_load('node', $nids);
foreach ($nodes as $node) {
media_gallery_remove_item_from_gallery($node, $file);
}
}
}