Add print logo
Logo cannot be displayed as a background image because it won't be
visible in print unless the user prints backgrounds too.
A sample configuration looks like this:
$wgVectorPrintLogo = [
'url' => 'https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-en.svg',
'width' => 174,
'height' => 27
];
The solution presented in the patch has a downside of not being able
to scale images down if their dimensions are bigger than the
dimensions specified in the config variable. For example, if we want
to go with an SVG image, then IE8 won't be able to render it.
Alternatively, if we want to go with a PNG image, its dimensions need
to match the exact dimensoins in the config variable, otherwise the
image will show up larger or smaller depending on its dimensions.
A more complicated approach of scaling images using `transform: scale`
hasn't been used because we wanted to keep the configuration simple
while supporting the majority of our users. With the current change,
we can reuse the existing configuration options from Minerva, for
exmaple. It would look something like this:
$wgVectorPrintLogo = [
'url' => $wgMFCustomLogos['copyright'],
'width' => $wgMFCustomLogos['copyright-width'],
'height' => $wgMFCustomLogos['copyright-height']
];
Bug: T169826
Change-Id: If8f9f8d95fd3c955ece37d6c8ab6995596189667
2017-07-19 19:27:55 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ResourceLoader module for print styles.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Vector;
|
|
|
|
|
|
|
|
use CSSMin;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
use ResourceLoaderContext;
|
|
|
|
use ResourceLoaderFileModule;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ResourceLoader module for print styles.
|
|
|
|
*/
|
|
|
|
class ResourceLoaderLessModule extends ResourceLoaderFileModule {
|
|
|
|
/**
|
|
|
|
* Get language-specific LESS variables for this module.
|
|
|
|
*
|
|
|
|
* @param ResourceLoaderContext $context
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getLessVars( ResourceLoaderContext $context ) {
|
|
|
|
$lessVars = parent::getLessVars( $context );
|
|
|
|
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'vector' );
|
|
|
|
$printLogo = $config->get( 'VectorPrintLogo' );
|
|
|
|
if ( $printLogo ) {
|
|
|
|
$lessVars[ 'printLogo' ] = true;
|
2017-08-04 15:06:32 +00:00
|
|
|
$lessVars[ 'printLogoUrl' ] = CSSMin::buildUrlValue(
|
|
|
|
CSSMin::encodeImageAsDataURI( $printLogo['url'] ) );
|
Add print logo
Logo cannot be displayed as a background image because it won't be
visible in print unless the user prints backgrounds too.
A sample configuration looks like this:
$wgVectorPrintLogo = [
'url' => 'https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-en.svg',
'width' => 174,
'height' => 27
];
The solution presented in the patch has a downside of not being able
to scale images down if their dimensions are bigger than the
dimensions specified in the config variable. For example, if we want
to go with an SVG image, then IE8 won't be able to render it.
Alternatively, if we want to go with a PNG image, its dimensions need
to match the exact dimensoins in the config variable, otherwise the
image will show up larger or smaller depending on its dimensions.
A more complicated approach of scaling images using `transform: scale`
hasn't been used because we wanted to keep the configuration simple
while supporting the majority of our users. With the current change,
we can reuse the existing configuration options from Minerva, for
exmaple. It would look something like this:
$wgVectorPrintLogo = [
'url' => $wgMFCustomLogos['copyright'],
'width' => $wgMFCustomLogos['copyright-width'],
'height' => $wgMFCustomLogos['copyright-height']
];
Bug: T169826
Change-Id: If8f9f8d95fd3c955ece37d6c8ab6995596189667
2017-07-19 19:27:55 +00:00
|
|
|
$lessVars[ 'printLogoWidth' ] = intval( $printLogo['width'] );
|
|
|
|
$lessVars[ 'printLogoHeight' ] = intval( $printLogo['height'] );
|
|
|
|
} else {
|
|
|
|
$lessVars[ 'printLogo' ] = false;
|
|
|
|
}
|
|
|
|
return $lessVars;
|
|
|
|
}
|
|
|
|
}
|