mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-24 06:24:22 +00:00
Allow to make thumbnail size configurable
This commit is contained in:
parent
85f1ea1e91
commit
423e7c0eea
|
@ -88,6 +88,15 @@ class CitizenHooks {
|
|||
* @return bool
|
||||
*/
|
||||
public static function onThumbnailBeforeProduceHTML( $thumb, &$attribs, &$linkAttribs ) {
|
||||
try {
|
||||
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Citizen' );
|
||||
$thumbSize = $config->get( 'ThumbnailSize' );
|
||||
} catch ( ConfigException $e ) {
|
||||
wfLogWarning( sprintf( 'Could not get config for "$wgThumbnailSize". Defaulting to "10". %s',
|
||||
$e->getMessage() ) );
|
||||
$thumbSize = 10;
|
||||
}
|
||||
|
||||
$file = $thumb->getFile();
|
||||
|
||||
if ( $file !== null ) {
|
||||
|
@ -112,7 +121,8 @@ class CitizenHooks {
|
|||
$attribs['data-height'] = $attribs['height'];
|
||||
|
||||
// Replace src with small size image
|
||||
$attribs['src'] = preg_replace( '#/\d+px-#', '/10px-', $attribs['src'] );
|
||||
$attribs['src'] =
|
||||
preg_replace( '#/\d+px-#', sprintf( '/%upx-', $thumbSize ), $attribs['src'] );
|
||||
|
||||
// So that the 10px thumbnail is enlarged to the right size
|
||||
$attribs['width'] = $attribs['data-width'];
|
||||
|
|
|
@ -164,6 +164,12 @@
|
|||
"description": "Page tools visibility condition",
|
||||
"descriptionmsg": "citizen-config-showpagetools",
|
||||
"public": true
|
||||
},
|
||||
"ThumbnailSize": {
|
||||
"value": 10,
|
||||
"description": "Thumbnail size to use for lazy-loading",
|
||||
"descriptionmsg": "citizen-config-thumbnailsize",
|
||||
"public": true
|
||||
}
|
||||
},
|
||||
"ConfigRegistry": {
|
||||
|
|
Loading…
Reference in a new issue