Page MenuHomePhabricator

How can I enable srcset on mobile devices?
Closed, ResolvedPublic

Description

I have $wgResponsiveImages = true; but on mobile I get no srcset.

This is primarily targeted at mobile and tablet browsers and some newer laptops such as the 'Retina' MacBook Pro.

This contradicts. How can I enable srcset on mobile devices?

MW 1.25

Event Timeline

Subfader created this task.May 1 2016, 3:19 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 1 2016, 3:19 PM
Subfader updated the task description. (Show Details)May 1 2016, 3:21 PM
Subfader updated the task description. (Show Details)
Subfader updated the task description. (Show Details)
Subfader updated the task description. (Show Details)
brion added a subscriber: brion.

Removing srcset on mobile was Performance's thing. Tagging.

Subfader added a comment.EditedMay 1 2016, 3:45 PM

I'm not sure I get no srcset on mobile.

On desktop, in the Chrome dev tools def not (window.devicePixelRatio = 2 tho).
Maybe it's jquery.hidpi.js being smarter and recognizing the emulation?

On mobile when "open the image" of a 180px thumb, the 360px thumb opens, so it seems to work.

MW 1.25, as said.

brion added a comment.May 1 2016, 4:00 PM

The jquery.hidpi module is a polyfill for implementing a subset of srcset selection at runtime on browsers that do not support it natively; it will thus not activate on any current modern browser. You may 100% ignore it for this reason.

The question is, are the srcset attributes present?

ori added a subscriber: ori.May 1 2016, 4:33 PM

Try purging a page to determine whether the missing srcset attributes are an artifact of caching.

The question is, are the srcset attributes present?

On desktop: Yes.

Chrome dev tools mobile device emulator: No.

On mobile device: How to check properly? "Open image" opens the 2x size.

Subfader added a comment.EditedMay 1 2016, 7:46 PM

When was it removed anyway? Can I enable it via a global when I update fom MW 1.25?

Jdlrobson added a subscriber: Jdlrobson.

Right now this is not configurable.
It is stripped as part of https://gerrit.wikimedia.org/r/#/c/271141/

It would be trivial to add a config setting wgMFResponsiveImages which defaults to false and is checked in the onThumbnailBeforeProduceHTML hook

https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/includes/MobileFrontend.hooks.php#L1302

Patches welcomed.

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptMay 2 2016, 5:53 PM

Thanks, I'll check that on the next update.

Change 286502 had a related patch set uploaded (by Brion VIBBER):
Add $wgMFStripResponsiveImages setting, defaulting back to off

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

brion added a comment.May 2 2016, 7:41 PM

I noticed that in the current code, there's no parser cache hash key change to distinguish between srcset-removal and non-srcset-removal mode. This meant that srcset got stripped depending on the view at *rendering time* not the view at *display time*.

Patch adds a parser key hash key tweak as well as the setting.

Jdlrobson triaged this task as Low priority.May 9 2016, 5:15 PM

I'll look to SWAT this.

Change 286505 had a related patch set uploaded (by Jdlrobson):
Enable $wgMFStripResponsiveImages

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

When was it removed anyway?

https://www.mediawiki.org/wiki/HiDPI_display_support has some more background. (This was also mentioned in Tech News at some point.)

Change 286505 merged by jenkins-bot:
Enable $wgMFStripResponsiveImages

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

Change 286502 merged by jenkins-bot:
Add $wgMFStripResponsiveImages setting, defaulting on

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