From: Joey Hess <joey@kitenet.net>
Date: Tue, 14 Jun 2011 18:08:13 +0000 (-0400)
Subject: fixed previewing of attachments from holding area
X-Git-Tag: 3.20110707~60^2~24
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/c55a32d3e18e5ed72be0dd74461f33ee5e39ef12

fixed previewing of attachments from holding area
---

diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index 06b0c6c51..eb8846d06 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -103,6 +103,12 @@ sub formbuilder_setup (@) {
 		else {
 			$form->tmpl_param("attachments-class" => "toggleable-open");
 		}
+		
+		# Save attachments in holding area before previewing so
+		# they can be seen in the preview.
+		if ($form->submitted eq "Preview") {
+			attachments_save($form, $params{session});
+		}
 	}
 }
 
@@ -118,7 +124,7 @@ sub formbuilder (@) {
             ($form->submitted eq "Upload Attachment" || $form->submitted eq "Save Page")) {
 		attachment_store($filename, $form, $q, $params{session});
 	}
-	if ($form->submitted eq "Save Page" || $form->submitted eq "Preview") {
+	if ($form->submitted eq "Save Page") {
 		attachments_save($form, $params{session});
 	}