Brion VIBBER has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/286502

Change subject: Add $wgMFStripResponsiveImages setting, defaulting back to off
......................................................................

Add $wgMFStripResponsiveImages setting, defaulting back to off

Introduces $wgMFStripResponsiveImages setting, defaulting to off
to restore previous default behavior of not removing srcset attributes
on the mobile view.

Also adds the setting to the parser cache hash key -- previously,
srcset would be stripped from the parser cache on mobile *renderings*
but still *served to desktop* or vice versa.

Bug: T134115
Change-Id: Icc1246e2b109e48ec5d178c146a779980ce6c196
---
M extension.json
M includes/MobileFrontend.hooks.php
2 files changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/02/286502/1

diff --git a/extension.json b/extension.json
index 210cf29..c23f249 100644
--- a/extension.json
+++ b/extension.json
@@ -2061,7 +2061,9 @@
                "MFSchemaEditSampleRate": 0.0625,
                "MFAllowNonJavaScriptEditing": false,
                "@MinervaAlwaysShowLanguageButton": "Whether to show the 
language switcher button even if no languages are available for the page.",
-               "MinervaAlwaysShowLanguageButton": true
+               "MinervaAlwaysShowLanguageButton": true,
+               "@MFStripResponsiveImages": "Whether to strip 'srcset' 
attributes from all images on mobile renderings. This can be used as a sort of 
brute-force bandwidth optimization at the cost of making images fuzzier on most 
devices.",
+               "MFStripResponsiveImages": false,
        },
        "manifest_version": 1
 }
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 0672380..bc59883 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -377,6 +377,7 @@
         * @param array &$forOptions Array of options used to generate the 
$confstr hash key
         */
        public static function onPageRenderingHash( &$confstr, User $user, 
&$forOptions ) {
+               global $wgMFStripResponsiveImages;
                $context = MobileContext::singleton();
 
                if ( !$context->shouldDisplayMobileView() ) {
@@ -389,6 +390,10 @@
 
                if ( $context->imagesDisabled() ) {
                        $confstr .= '!noimg';
+               }
+
+               if ( $wgMFStripResponsiveImages ) {
+                       $confstr .= '!nosrcset';
                }
        }
 
@@ -1301,7 +1306,15 @@
         */
        public static function onThumbnailBeforeProduceHTML( $thumbnail, 
&$attribs, &$linkAttribs ) {
                if ( MobileContext::singleton()->shouldDisplayMobileView() ) {
-                       unset( $attribs['srcset'] );
+                       global $wgMFStripResponsiveImages;
+                       if ( $wgMFStripResponsiveImages ) {
+                               // 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'] );
+                       }
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/286502
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc1246e2b109e48ec5d178c146a779980ce6c196
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <br...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to