User:Sysy~metawiki/Patrick Felsted ImageLink Extension

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
Blue Glass Arrow.svg MediaWiki logo.png
This page should be moved to
Please do not move the page by hand. It will be imported by a administrator with the full edit history. In the meantime, you may continue to edit the page as normal.

I was having trouble with Joshua_Oreman's icon extension so I decided to make a really simple one that works on my MediaWiki site. This is based on Joshua's code, Thanks Joshua. Here is the code:

# To use this:
# <imglink src='MyImage' href='url' border='0' width='100' height='100' ></imglink>


$wgExtensionFunctions[] = "wfImageLink";

function wfImageLink()
  global $wgParser;
  $wgParser->setHook ("imglink", "renderImageLink");

function renderImageLink ($input, $argv)
   $href = $argv["href"];
   $border = $argv["border"];
   $src = $argv["src"];
   $height = $argv["height"];
   $width = $argv["width"];

   $itag = "<a href='$href' ><img border='$border' src='" . Image::imageUrl($src) . "' width='$width' height='$height' /></a>";
   return str_replace ($ret, "IMAGE", $itag);