changeset 3307:f4212fb5ecb0

EmbedObject: fixed bug for image mimetype and configured when to call EmbedObject
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 18 Mar 2008 19:43:45 +0100
parents e50210d37a8d
children 6eb96b8664b0 3f61d2b76e23
files MoinMoin/action/AttachFile.py MoinMoin/macro/EmbedObject.py MoinMoin/parser/text_moin_wiki.py
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Tue Mar 18 19:22:01 2008 +0100
+++ b/MoinMoin/action/AttachFile.py	Tue Mar 18 19:43:45 2008 +0100
@@ -950,7 +950,9 @@
     request.write('%s<br><br>' % link)
 
     mt = wikiutil.MimeType(filename=filename)
-    if mt.major == 'image':
+
+    # later on we can add svg too. (destinguishs if browser need a plugin in place)
+    if mt.major == 'image' and mt.minor in ('jpg', 'jpeg', 'png', 'gif'):
         request.write('<img src="%s" alt="%s">' % (
             getAttachUrl(pagename, filename, request, escaped=1),
             wikiutil.escape(filename, 1)))
--- a/MoinMoin/macro/EmbedObject.py	Tue Mar 18 19:22:01 2008 +0100
+++ b/MoinMoin/macro/EmbedObject.py	Tue Mar 18 19:43:45 2008 +0100
@@ -158,12 +158,13 @@
     "alt": wikiutil.escape(alt),
 }
 
-    if mt.major in ['image', 'chemical', 'x-world']:
+    elif mt.major in ['image', 'chemical', 'x-world']:
         embed_src = '''
 <object %(ob_data)s %(ob_type)s  %(ob_width)s %(ob_height)s %(ob_align)s>
-<param name="%(major)s" value="%(url)s">
+%(name)s"
 <p>%(alt)s</p>
 </object>''' % {
+    "mime_type": mime_type,
     "ob_data": _check_object_value("data", url),
     "ob_width": _check_object_value("width", width),
     "ob_height": _check_object_value("height", height),
@@ -173,7 +174,7 @@
     "alt": wikiutil.escape(alt),
 }
 
-    if mt.major == 'audio':
+    elif mt.major == 'audio':
         if not width and not height:
             width = '400px'
             height = '100px'
@@ -196,7 +197,7 @@
     "alt": wikiutil.escape(alt),
 }
 
-    if mt.major == 'application':
+    elif mt.major == 'application':
         # workaround for the acroread not knowing the size to embed
         if mt.minor == 'pdf':
             width = width or '800px'
--- a/MoinMoin/parser/text_moin_wiki.py	Tue Mar 18 19:22:01 2008 +0100
+++ b/MoinMoin/parser/text_moin_wiki.py	Tue Mar 18 19:43:45 2008 +0100
@@ -707,7 +707,8 @@
                     if mt.major == 'text':
                         desc = self._transclude_description(desc, url)
                         return self.formatter.attachment_inlined(url, desc)
-                    elif mt.major == 'image':
+                    # later on we can add svg too. (destinguishs if browser need a plugin in place)
+                    elif mt.major == 'image' and mt.minor in ('jpg', 'jpeg', 'png', 'gif'):
                         desc = self._transclude_description(desc, url)
                         tag_attrs, query_args = self._get_params(params,
                                                                  tag_attrs={'alt': desc,