summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoloc2012-12-12 20:17:09 (GMT)
committer Moloc2012-12-12 20:17:09 (GMT)
commit7c3c9bc3ee06e2f0c32d6be142762b4583fd639a (patch)
tree099c9379a1e4dbbf929b91ae6f0a61ce3572bdba
parent533c0290ac80b626b037529ef08cce33079178eb (diff)
Issue #1715422 by jsagotsky, Moloc: Fixed deleting files are not removed from media_gallery.
-rw-r--r--media_gallery.module20
1 files changed, 20 insertions, 0 deletions
diff --git a/media_gallery.module b/media_gallery.module
index aaaf781..3e315f9 100644
--- a/media_gallery.module
+++ b/media_gallery.module
@@ -258,6 +258,26 @@ function media_gallery_node_load($nodes, $types) {
}
/**
+ * Implements hook_file_delete().
+ *
+ * When an image is deleted, remove it from media_gallery nodes first.
+ */
+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);
+ }
+ }
+}
+
+/**
* Implements hook_view().
*/
function media_gallery_view($node, $view_mode) {