diff --git a/includes/CitizenHooks.php b/includes/CitizenHooks.php index ced426f0..66644a36 100644 --- a/includes/CitizenHooks.php +++ b/includes/CitizenHooks.php @@ -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']; diff --git a/skin.json b/skin.json index 45a89e78..0630deb5 100644 --- a/skin.json +++ b/skin.json @@ -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": {