Wiki source for Mod019fInlineImages


Show raw source

==== Wikka Mod 019 ====
Type: Feature addition
----
===Credit:===
** Adrian Look **
[[http://web.archive.org/web/20040820215431/http://www.wakkawiki.com/InlineImages | 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 [[http://web.archive.org/web/20040603153701/http://www.wakkawiki.com/ImgAction | 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)
<?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)
<?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, [[http://web.archive.org/web/20040603153701/http://www.wakkawiki.com/ImgAction | ImgAction]] is still useful for cool stuff like alt tags, sizes, links, etc
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki