[wicked] Problem with embedded images (patch)

Adam Yearout adam at chameleonnetworks.net
Sun Mar 21 05:33:57 PST 2004


While playing around with the sample wiki page provided with Text_Wiki, 
I noticed that embedded images weren't working properly.  I was able to 
track it down to wicked/lib/Text_Wiki/url.php.  The class extension here 
breaks the URLs for embedded images by turning them into Horde external 
links.  I took existing code from Text_Wiki's url.php and applied it 
here so that URLs are only translated if they are not images.

--

Adam Yearout
adam at chameleonnetworks.net
-------------- next part --------------
--- url.php.orig	2004-03-21 04:26:11.000000000 -0800
+++ url.php	2004-03-21 05:21:30.000000000 -0800
@@ -29,8 +29,16 @@
      */
     function renderXhtml($options)
     {
-        $options['href'] = Horde::externalUrl($options['href']);
-        return parent::renderXhtml($options);
+        // determine the filename extension
+        $pos = strrpos($options['href'], '.');
+        $ext = strtolower(substr($options['href'], $pos));
+
+        // does the filename extension indicate an image file?
+        // if not, translate the URI into a Horde external link.
+        if (!in_array($ext, $this->img_ext)) {
+                $options['href'] = Horde::externalUrl($options['href']);
+        }
+        return parent::renderXhtml($options);    
     }
 
 }


More information about the wicked mailing list