Wikka Mod 019

Type: Feature addition

Credit:

Adrian Look
InlineImages @ WakkaWiki

Inline Images

To include an image just type in an URL to a jpeg or gif. No special formatting is necessary. No brackets or anything like that.

So if I wanted the Google logo to show up on this page, I just have to put http://www.google.com/images/logo.gif....
http://www.google.com/images/logo.gif



Implementation

A simple alternative to ImgAction would be to modify URL matching in formatters/wakka.php. This converts gif, jpg, and png URLs into <img> tags rather than <a> tags. Of course, if you want to force a link, instead of an inline image, just use [[ | ]] as usual.

Add one line to formatters/wakka.php so that instead of:

<?php
        // urls
        else if (preg_match("/^([a-z]+:\/\/\S+?)([^[:alnum:]^\/])?$/", $thing, $matches)) {
            $url = $matches[1];
            return "<a href=\"$url\">$url</a>".$matches[2];
        }
?>


it now reads:

<?php
        // urls
        else if (preg_match("/^([a-z]+:\/\/\S+?)([^[:alnum:]^\/])?$/", $thing, $matches)) {
            $url = $matches[1];
            if (preg_match("/^(.*)\.(gif|jpg|png)/si", $url)) return "<img src=\"$url\" />".$matches[2];
            return "<a href=\"$url\">$url</a>".$matches[2];
        }
?>


Of course, ImgAction is still useful for cool stuff like alt tags, sizes, links, etc
Comments
Comment by GmBowen
2004-10-24 02:49:30
Is there some way of DE-activating in-line images?? I don't want users to be able to just put in a url and have an image appear.
Comment by DarTar
2004-10-24 17:07:04
Mike, you'll need to comment out the following lines from formatters/wakka.php:

if (preg_match("/^(.*)\.(gif|jpg|png)/si", $url)) {
return "<img src=\"$url\" alt=\"image\" />".$matches[2];
} else
Comment by GmBowen
2004-11-08 14:52:00
Thanks DarTar. I was obviously sleepy when I wrote the above....duh, I could just REMOVE the mod. LOL. When I did that I still had active links EXCEPT I didn't have in-line image support.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki