This commit is contained in:
Max Semenik 2012-02-29 14:50:36 +04:00
parent fb828b5361
commit 6d258671b5
2 changed files with 36 additions and 0 deletions

24
PageImages.body.php Normal file
View file

@ -0,0 +1,24 @@
<?php
class PageImages {
public static function registerImage( Title $title, File $file, &$params, Parser $parser ) {
$out = $parser->getOutput();
if ( !isset( $out->pageImages ) ) {
$out->pageImages = array();
}
$myParams = $params;
if ( !isset( $myParams['handler']['width'] ) ) {
$myParams['handler']['width'] = $file->getWidth();
}
$out->pageImages[$title->getDBkey()] = $myParams;
return true;
}
public static function getProperties( LinksUpdate $lu ) {
if ( !isset( $lu->getParserOutput()->pageImages ) ) {
return true;
}
$images = $lu->getParserOutput()->pageImages;
return true;
}
}

View file

@ -1 +1,13 @@
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
die;
}
define( 'PAGE_IMAGES_INSTALLED', true );
$dir = dirname( __FILE__ );
$wgAutoloadClasses['PageImages'] = "$dir/PageImages.body.php";
$wgHooks['ParserMakeImageParams'][] = 'PageImages::registerImage';
$wgHooks['LinksUpdate'][] = 'PageImages::getProperties';