jenkins-bot has submitted this change and it was merged.
Change subject: Whitelist rasterized SVG images for srcset density-responsive
output
......................................................................
Whitelist rasterized SVG images for srcset density-responsive output
SVG rasterizations are usually diagrams that compress well, and
benefit more from the higher resolution output than photos do.
Can add other types in $wgMFResponsiveImageWhitelist, by mime type
of the source file.
Bug: T133496
Change-Id: Ib338198315b8c74133eac56be20603012b8f9a3f
---
M extension.json
M includes/MobileFrontend.hooks.php
2 files changed, 18 insertions(+), 7 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index feb51e8..5a208ac 100644
--- a/extension.json
+++ b/extension.json
@@ -2082,7 +2082,11 @@
"@MinervaAlwaysShowLanguageButton": "Whether to show the
language switcher button even if no languages are available for the page.",
"MinervaAlwaysShowLanguageButton": true,
"@MFStripResponsiveImages": "Whether to strip 'srcset'
attributes from all images on mobile renderings. This is a sort of brute-force
bandwidth optimization at the cost of making images fuzzier on most devices.",
- "MFStripResponsiveImages": true
+ "MFStripResponsiveImages": true,
+ "@MFResponsiveImageWhitelist": "Whitelist of source file mime
types to retain srcset attributes on when using $wgMFStripResponsiveImages.
Defaults to allow rasterized SVGs since they usually are diagrams that compress
well and benefit from the higher resolution.",
+ "MFResponsiveImageWhitelist": [
+ "image/svg+xml"
+ ]
},
"manifest_version": 1
}
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index 322c909..7c92ca5 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -1295,15 +1295,22 @@
*/
public static function onThumbnailBeforeProduceHTML( $thumbnail,
&$attribs, &$linkAttribs ) {
$context = MobileContext::singleton();
+ $config = $context->getMFConfig();
if (
$context->shouldDisplayMobileView() &&
- $context->getMFConfig()->get( 'MFStripResponsiveImages'
)
+ $config->get( 'MFStripResponsiveImages' )
) {
- // Remove all responsive image 'srcset' attributes.
- // Note that in future, srcset may be used for
specifying
- // small-screen-friendly image variants as well as
density
- // variants, so this should be used with caution.
- unset( $attribs['srcset'] );
+ $file = $thumbnail->getFile();
+ if ( !$file || !in_array( $file->getMimeType(),
+ $config->get(
'MFResponsiveImageWhitelist' ) ) ) {
+ // Remove all responsive image 'srcset'
attributes, except
+ // from SVG->PNG renderings which usually
aren't too huge,
+ // or other whitelisted types.
+ // Note that in future, srcset may be used for
specifying
+ // small-screen-friendly image variants as well
as density
+ // variants, so this should be used with
caution.
+ unset( $attribs['srcset'] );
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/286523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib338198315b8c74133eac56be20603012b8f9a3f
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits