ImageWithLink

From Sterbal's Sundry Studies
Jump to navigation Jump to search

About[edit]

ImageWithLink is a MediaWiki extension that adds a new tag:

<iwl></iwl>

Example:
<iwl>EXTERNAL-IMAGE-URL|LINK-TO-SITE|TEXT</iwl>

<iwl>http://api.flattr.com/button/flattr-badge-large.png|http://flattr.com/thing/571679/n0r1sk|Flattr this</iwl>

(the extension is not currently installed on this wiki)

Installation[edit]

  1. Create the file ImageWithLink.php from the text below in your MediaWiki extension directory. You can place it directly there or you can make a subfolder in the extensions directory.
  2. Edit your LocalSettings.php file. You'll find it in the root of your MediaWiki installation. Add the following code at the bottom of the file.
#ImageWithLink
require_once"$IP/extensions/ImageWithLink.php";


This php file lets a wiki show external images:

<?php
/**
This extension adds the ability to nearly use wiki syntax to create an external image with a link/url behind it.

Copyright (C) 2012 by
	Christof Alber,
	Mario Kleinsasser,
	Markus Neuhold,
	Bernhard Rausch,
	Martin Steinwender

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

$wgExtensionCredits['parserhook'][] = array(
       'path' => __FILE__,
       'name' => 'Image with Link',
       'author' =>'Christof Alber, Mario Kleinsasser, Markus Neuhold, Bernhard Rausch, Martin Steinwender', 
       'url' => 'https://www.n0r1sk.com', 
       'description' => 'This extension adds the ability to nearly use wiki syntax to create an external image with a link/url behind it - by [http://www.n0r1sk.com n0r1sk.com]',
       'version'  => 0.1,
       ); 
 
$wgHooks['ParserFirstCallInit'][] = 'ImageWithLinkInit';
 
function ImageWithLinkInit( &$parser ) {
	$parser->setHook( 'iwl', 'ImageWithLink' );
	return true;
}
 
function ImageWithLink( $input, array $args, Parser $parser, PPFrame $frame ) {
	/** $output = $parser->recursiveTagParse( $input, $frame); */
	list($image, $link, $text) = explode("|", $input);
	$output = '<a href="' . $link . '" target="_blank"><img src="' . $image . '" alt="' . $text . '" title="' . $text . '"></a>';
	return $output;
}


Notes[edit]

What Links Here[edit]