Extension:Full Local Image
![]() | This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
![]() | This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
Full Local Image Release status: unmaintained |
|
---|---|
Implementation | Parser function |
Description | Creates two parser-functions, localimage and fullimage, they work similar to the localurl and fullurl functions except they return the path to an image not a article. |
Author(s) | Daniel Friesen (Dantmantalk) |
MediaWiki | all versions |
License | No license specified |
Download | see below Changelog |
This Full Local Image extension was 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 targeted currently for the MediaWiki 1.6.5 versions.
Parser functions[edit]
This extension adds two parser functions 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.
Code[edit]
To install add the following files to your wiki and use this in your LocalSettings.php to install it:
require_once( "extensions/FullLocalImage.php" );
extensions/FullLocalImage.php[edit]
<?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;
}
Changelog[edit]
- 31/10/2006 – Updated code. (untested)
- 31/10/2006 – Added this page. (under development)