Jump to content

User:Sysy~metawiki/Patrick Felsted ImageLink Extension

From Meta, a Wikimedia project coordination wiki
 
A proposal to move this page to MediaWiki.org was rejected.

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