User:Sysy~metawiki/Patrick Felsted ImageLink Extension

Blue Glass Arrow.svg MediaWiki-2020-logo.svg
This page should be moved to MediaWiki.org.
Please do not move the page by hand. It will be imported by a MediaWiki.org 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:

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

require_once("Image.php");

$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);
}