From: isarra Date: Mon, 9 Mar 2015 01:55:31 +0000 (+0000) Subject: Add support for HD versions of the wiki logo in MonoBook-like skins. X-Git-Tag: 1.31.0-rc.0~12113^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=b5f2cf2db1adea872b0bd676d729ebfe84538a24;p=lhc%2Fweb%2Fwiklou.git Add support for HD versions of the wiki logo in MonoBook-like skins. Done using an array $wgLogoHD, which expects something like the following: $wgLogoHD = array( "1.5x" => "path/to/1.5x_version.png", "2x" => "path/to/2x_version.png" ); This is still horrible, but I dunno how to make it less horrible. Help. Bug: T37337 Change-Id: Iee3e73c1f96b81c2094418986cf1c267d93d1bdd --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8080774ffb..bc6db86243 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -257,6 +257,23 @@ $wgFileCacheDirectory = false; */ $wgLogo = false; +/** + * Array with URL paths to HD versions of the wiki logo. The scaled logo size + * should be under 135x155 pixels. + * Only 1.5x and 2x versions are supported. + * + * @par Example: + * @code + * $wgLogoHD = array( + * "1.5x" => "path/to/1.5x_version.png", + * "2x" => "path/to/2x_version.png" + * ); + * @endcode + * + * @since 1.25 + */ +$wgLogoHD = false; + /** * The URL path of the shortcut icon. * @since 1.6 diff --git a/includes/resourceloader/ResourceLoaderSkinModule.php b/includes/resourceloader/ResourceLoaderSkinModule.php index 983593269b..3ba63e6822 100644 --- a/includes/resourceloader/ResourceLoaderSkinModule.php +++ b/includes/resourceloader/ResourceLoaderSkinModule.php @@ -31,11 +31,33 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule { */ public function getStyles( ResourceLoaderContext $context ) { $logo = $this->getConfig()->get( 'Logo' ); + $logoHD = $this->getConfig()->get( 'LogoHD' ); $styles = parent::getStyles( $context ); $styles['all'][] = '.mw-wiki-logo { background-image: ' . CSSMin::buildUrlValue( $logo ) . '; }'; - + if ( $logoHD ) { + if ( isset( $logoHD['1.5x'] ) ) { + $styles[ + '(-webkit-min-device-pixel-ratio: 1.5), ' . + '(min--moz-device-pixel-ratio: 1.5), ' . + '(min-resolution: 1.5dppx), ' . + '(min-resolution: 144dpi)' + ][] = '.mw-wiki-logo { background-image: ' . + CSSMin::buildUrlValue( $logoHD['1.5x'] ) .';' . + 'background-size: 135px auto; }'; + } + if ( isset( $logoHD['2x'] ) ) { + $styles[ + '(-webkit-min-device-pixel-ratio: 2), ' . + '(min--moz-device-pixel-ratio: 2),'. + '(min-resolution: 2dppx), ' . + '(min-resolution: 192dpi)' + ][] = '.mw-wiki-logo { background-image: ' . + CSSMin::buildUrlValue( $logoHD['2x'] ) . ';' . + 'background-size: 135px auto; }'; + } + } return $styles; } @@ -64,6 +86,7 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule { */ public function getModifiedHash( ResourceLoaderContext $context ) { $logo = $this->getConfig()->get( 'Logo' ); - return md5( parent::getModifiedHash( $context ) . $logo ); + $logoHD = $this->getConfig()->get( 'LogoHD' ); + return md5( parent::getModifiedHash( $context ) . $logo . json_encode( $logoHD ) ); } }