Brion VIBBER has uploaded a new change for review. https://gerrit.wikimedia.org/r/293893
Change subject: Don't strip srcset on API mobileview action ...................................................................... Don't strip srcset on API mobileview action The old config hack had the effect that the mobileview API was still using srcset, which the app relied on having for full resolution availability (it can then at runtime strip or use them). Now using explicit override of the local config to restore that behavior while being consistent with the new config. Bug: T137608 Change-Id: Ice0e48d566e95f342c3d1554899e2715c836bc2b --- M includes/MobileContext.php M includes/MobileFrontend.hooks.php M includes/api/ApiMobileView.php 3 files changed, 35 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/93/293893/1 diff --git a/includes/MobileContext.php b/includes/MobileContext.php index c2c6725..4513aae 100644 --- a/includes/MobileContext.php +++ b/includes/MobileContext.php @@ -1129,4 +1129,33 @@ $this->addAnalyticsLogItem( 'mf-m', 'b' ); } } + + /** + * Process-local override for MFStripResponsiveImages, used by + * the mobileview API request. + */ + private $stripResponsiveImagesOverride = null; + + /** + * Should image thumbnails in pages remove the high-density additions + * during this request? + * + * @return boolean + */ + public function shouldStripResponsiveImages() { + if ( $this->stripResponsiveImagesOverride === null ) { + return $this->getMFConfig()->get( 'MFStripResponsiveImages' ); + } else { + return $this->stripResponsiveImagesOverride; + } + } + + /** + * Config override for responsive image strip mode. + * + * @param boolean $val + */ + public function setStripResponsiveImages( $val ) { + $this->stripResponsiveImagesOverride = $val; + } } diff --git a/includes/MobileFrontend.hooks.php b/includes/MobileFrontend.hooks.php index 797bf57..fed9819 100644 --- a/includes/MobileFrontend.hooks.php +++ b/includes/MobileFrontend.hooks.php @@ -385,7 +385,7 @@ return; } - if ( $context->getMFConfig()->get( 'MFStripResponsiveImages' ) ) { + if ( $context->shouldStripResponsiveImages() ) { $confstr .= '!responsiveimages=0'; } @@ -1303,7 +1303,7 @@ $config = $context->getMFConfig(); if ( $context->shouldDisplayMobileView() && - $config->get( 'MFStripResponsiveImages' ) + $context->shouldStripResponsiveImages() ) { $file = $thumbnail->getFile(); if ( !$file || !in_array( $file->getMimeType(), diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php index 2ca20bc..49687ed 100644 --- a/includes/api/ApiMobileView.php +++ b/includes/api/ApiMobileView.php @@ -50,6 +50,10 @@ // Logged-in users' parser options depend on preferences $this->getMain()->setCacheMode( 'anon-public-user-private' ); + // Don't strip srcset on renderings for mobileview api; the + // app below it will decide how to use them. + MobileContext::singleton()->setStripResponsiveImages( false ); + // Enough '*' keys in JSON!!! $isXml = $this->getMain()->isInternalMode() || $this->getMain()->getPrinter()->getFormat() == 'XML'; -- To view, visit https://gerrit.wikimedia.org/r/293893 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ice0e48d566e95f342c3d1554899e2715c836bc2b 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