mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-15 02:24:04 +00:00
Merge pull request #69 from octfx/feature/configurable_thumbsize
Allow to make thumbnail size configurable
This commit is contained in:
commit
3c3eb9c7a9
|
@ -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( 'CitizenThumbnailSize' );
|
||||
} 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