Extension:Full Local Image

From MediaWiki.org

Jump to: navigation, search

       

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Full Local Image

Release status: unknown

Implementation  Parser function
Description Creates 2 parserfunctions. Localimage and Fullimage, they work similar to the Localurl and Fullurl functions except they return the path to a image not a article.
Author(s)  Daniel Friesen (DantmanTalk)
MediaWiki  1.6.5
License No license specified
Download see below
Changelog

check usage (experimental)

The extension is most likely obsolete; it is available only for a very old mediawiki version and the purpose of allowing the use of images as links to other pages is since mediawiki 1.15 fullfilled with the "link =" parameter available to all wiki-images.

This Extension is under development for WikiIndex to allow the url of a local image to be inserted into a page in the same way {{fullurl:Articlename}} and {{localurl:Articlename}} are used. The main purpose for this is embedding local images into a page using the external embedding method so that the image can be used as a link.

Note: This extension is still under development and is targeted currently for the MediaWiki 1.6.5 versions.

Contents

[edit] Parserfunctions

This extension adds 2 parserfunctions that can be used.

{{fullimage:Imagename.ext}} {{localimage:Imagename.ext}}

Fullimage adds the full url to the image to the page, and Localimage adds the url to the page without the http://www.yoursite.com on it.

[edit] Code

To install add the following files to your wiki and use this in your LocalSettings.php to install it:

require_once( "extensions/FullLocalImage.php" );

[edit] extensions/FullLocalImage.php

<?php
/**
 * @Extension Full/Local Image
 * @Author Daniel Friesen (aka: Dantman )
 * @Description Creates 2 parserfunctions. Localimage and Fullimage, they work similar
 *      to the Localurl and Fullurl functions except they return the path to a image not a article.
 */
 
 
$wgExtensionFunctions[] = 'wfFLImage';
$wgHooks['LanguageGetMagic'][] = 'wfFLImageLanguageGetMagic';
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'Full/Local Image',
	'author' => 'Daniel Friesen (aka: Dantman )',
	'url' => 'http://www.mediawiki.org/wiki/Extension:Full_Local_Image'
);
 
function wfFLImage() {
	global $wgParser;
 
	$wgParser->setFunctionHook( 'Localimage', array( wgFLImageFuncts, 'Localimage' ), SFH_NO_HASH );
	$wgParser->setFunctionHook( 'Fullimage', array( wgFLImageFuncts, 'Fullimage' ), SFH_NO_HASH );
}
 
class wgFLImageFuncts {
	function Localimage ( &$parser, $name = '', $arg = null ) {
		$img = Image::newFromName( $name );
		if( $img != NULL ) return $img->getURL();
		return '';
	}
	function Fullimage ( &$parser, $name = '', $arg = null ) {
		global $wgServer;
		$img = Image::newFromName( $name );
		if( $img != NULL ) return $wgServer . $img->getURL();
		return '';
	}
}
 
# Register the magic words
function wfFLImageLanguageGetMagic( &$magicWords,$langCode = 0 ) {
	$magicWords['Localimage'] = array(0,'Localimage');
	$magicWords['Fullimage'] = array(0,'Fullimage');
	return true;
}

[edit] Changelog

  • 31/10/2006 - Updated code. (Untested)
  • 31/10/2006 - Added this page. (Under Development)