Mediawiki file size/description

From Bjoern Hassler

Jump to: navigation, search

Using info about parser functions here http://www.mediawiki.org/wiki/Manual:Parser_functions and http://organicdesign.co.nz/MediaWiki_code_snippets Bjoern built a simple function to scale images and get filesizes, see Mediawiki file size.

$title = Title::newFromText($v, NS_IMAGE);
$image = Image::newFromTitle($title);
if ($image && $image->exists()) {
	$url      = $image->getURL();                      # Gets the URL for the image at its normal size
	$url_50px = $image->getThumbnail(50,50)->getUrl(); # Gets the URL for the image at a specified size
}

During testing, it helps to disable the cache

## Disable all forms of MediaWiki caching
$wgMainCacheType = CACHE_NONE;
$wgMessageCacheType = CACHE_NONE;
$wgParserCacheType = CACHE_NONE;
$wgCachePages = false;

http://thinkhole.org/wp/2006/09/13/disabling-caching-in-mediawiki/