diff --git a/include/class.faq.php b/include/class.faq.php
index 555fd3aee7f6f01fb485259e338c13c394dc826b..38e20b55cfa14b176eeae22913f96448e8b850d3 100644
--- a/include/class.faq.php
+++ b/include/class.faq.php
@@ -405,7 +405,7 @@ class FAQ extends VerySimpleModel {
         }
 
         $images = Draft::getAttachmentIds($vars['answer']);
-        $images = array_map(function($i) { return $i['id']; }, $images);
+        $images = array_flip(array_map(function($i) { return $i['id']; }, $images));
         $this->getAttachments()->keepOnlyFileIds($images, true);
 
         // Handle language-specific attachments
diff --git a/include/class.page.php b/include/class.page.php
index a430fc2e66cd20da6b5a1711b1739094bbc8fdbc..1eb7387108f6ea98febbf1130cdc051cb8bf67f3 100644
--- a/include/class.page.php
+++ b/include/class.page.php
@@ -282,7 +282,7 @@ class Page extends VerySimpleModel {
 
         // Attach inline attachments from the editor
         $keepers = Draft::getAttachmentIds($vars['body']);
-        $keepers = array_map(function($i) { return $i['id']; }, $keepers);
+        $keepers = array_flip(array_map(function($i) { return $i['id']; }, $keepers));
         $this->attachments->keepOnlyFileIds($keepers, true);
 
         if ($rv)