mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-14 11:24:43 +00:00
Display page image on action=info
Show the page image as one item under "Basic information" on action=info. Bug: 64178 Change-Id: Id561c817fdda057c9dd8beae275c3b978b4dd20a
This commit is contained in:
parent
566ce74936
commit
587bf22f51
|
@ -133,6 +133,45 @@ class PageImages {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* InfoAction hook handler, adds the page image to the info=action page
|
||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/InfoAction
|
||||
* @param IContextSource $context
|
||||
* @param array $pageInfo
|
||||
* @return bool
|
||||
*/
|
||||
public static function onInfoAction( IContextSource $context, &$pageInfo ) {
|
||||
global $wgDefaultUserOptions, $wgThumbLimits;
|
||||
|
||||
wfProfileIn( __METHOD__ );
|
||||
$imageFile = self::getPageImage( $context->getTitle() );
|
||||
if ( $imageFile === null ) {
|
||||
// The page has no image
|
||||
wfProfileOut( __METHOD__ );
|
||||
return true;
|
||||
}
|
||||
|
||||
$thumbSetting = $context->getUser()->getOption(
|
||||
'thumbsize',
|
||||
$wgDefaultUserOptions['thumbsize']
|
||||
);
|
||||
$thumbSize = $wgThumbLimits[$thumbSetting];
|
||||
|
||||
$imageHtml = $imageFile->transform( array( 'width' => $thumbSize ) )->toHtml(
|
||||
array(
|
||||
'alt' => $imageFile->getTitle()->getText(),
|
||||
'desc-link' => true,
|
||||
)
|
||||
);
|
||||
|
||||
$pageInfo['header-basic'][] = array(
|
||||
$context->msg( 'pageimages-info-label' ),
|
||||
$imageHtml
|
||||
);
|
||||
wfProfileOut( __METHOD__ );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenSearchXml hook handler, enhances Extension:OpenSearchXml results with this extension's data
|
||||
* @param array $results
|
||||
|
|
|
@ -23,6 +23,7 @@ $wgExtensionMessagesFiles['PageImages'] = __DIR__ . "/PageImages.i18n.php";
|
|||
$wgHooks['ParserMakeImageParams'][] = 'PageImages::onParserMakeImageParams';
|
||||
$wgHooks['LinksUpdate'][] = 'PageImages::onLinksUpdate';
|
||||
$wgHooks['OpenSearchXml'][] = 'PageImages::onOpenSearchXml';
|
||||
$wgHooks['InfoAction'][] = 'PageImages::onInfoAction';
|
||||
|
||||
$wgAPIPropModules['pageimages'] = 'ApiQueryPageImages';
|
||||
|
||||
|
|
13
i18n/en.json
13
i18n/en.json
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": []
|
||||
},
|
||||
"pageimages-desc": "Collects information about images used on page",
|
||||
"pageimages-blacklist": ""
|
||||
}
|
||||
"@metadata": {
|
||||
"authors": []
|
||||
},
|
||||
"pageimages-desc": "Collects information about images used on page",
|
||||
"pageimages-blacklist": "",
|
||||
"pageimages-info-label": "Page image"
|
||||
}
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
]
|
||||
},
|
||||
"pageimages-desc": "{{desc|name=Page Images|url=http://www.mediawiki.org/wiki/Extension:PageImages}}",
|
||||
"pageimages-blacklist": "List of images. They will never be selected as page images"
|
||||
"pageimages-blacklist": "List of images. They will never be selected as page images",
|
||||
"pageimages-info-label": "Label for the page image field on the info=action page"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue