changeset 496:0fc6d8edd693

macro.Image: check if attachment exists
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 11 Feb 2010 22:34:09 +0100
parents 9b22669a0690
children a4e59a30d352
files data/plugin/macro/Image.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/Image.py	Thu Feb 04 23:44:49 2010 +0100
+++ b/data/plugin/macro/Image.py	Thu Feb 11 22:34:09 2010 +0100
@@ -12,7 +12,7 @@
     Requires PIL and ExifTags libs.
 
     @copyright: 2008 MoinMoin:ThomasWaldmann,
-                2008 MoinMoin:ReimarBauer
+                2008-2010 MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -244,6 +244,9 @@
 
         <<Image(PageName/attachname,width=100,alt="sample image")>>
     """
+    _ = macro.request.getText
+    if not AttachFile.exists(macro.request, macro.formatter.page.page_name, itemname):
+        return _("Attachment '%(filename)s' does not exist!") % {"filename": itemname}
     if '/' not in itemname:
         itemname = macro.formatter.page.page_name + '/' + itemname
     img = Image(macro.request, itemname, caption=alt)