Page MenuHomePhabricator

MediaViewer (and the commons file page) should serve WebP originals not thumbnails of equivalent size
Closed, ResolvedPublic

Description

As reported in T414805, we serve PNG thumbnails for WebP files. That's fine (although WebP is really very widely supported these days, so we might want to revisit that at some point), but currently rather than showing a WebP original, we instead serve a PNG thumbnail of the same size, which can be a non-standard size.

This can be seen e.g. https://commons.wikimedia.org/wiki/File:Myrlyn_1.0.0_screenshot.webp - both opening in MediaViewer on a large display will attempt to display a PNG (which is currently often instead presenting an error), and the largest "thumb" size under the image is the original-size-thumbnail.

In both cases, the WebP original should be displayed instead.

Details

Related Changes in Gerrit:
SubjectRepoBranchLines +/-
mediawiki/coreREL1_45+6 -8
mediawiki/coreREL1_44+6 -8
mediawiki/coreREL1_43+6 -8
mediawiki/corewmf/1.46.0-wmf.24+6 -8
mediawiki/coremaster+6 -8
mediawiki/coreREL1_45+27 -14
mediawiki/coreREL1_44+27 -14
mediawiki/coreREL1_43+27 -14
mediawiki/coreREL1_43+46 -30
mediawiki/coreREL1_44+45 -29
mediawiki/coreREL1_45+46 -30
mediawiki/coremaster+46 -30
mediawiki/coremaster+27 -14
mediawiki/coreREL1_45+54 -27
mediawiki/coreREL1_44+54 -27
mediawiki/coreREL1_43+54 -27
mediawiki/coreREL1_43+0 -8
mediawiki/coreREL1_44+0 -8
mediawiki/coreREL1_45+0 -8
mediawiki/corewmf/1.46.0-wmf.18+0 -8
mediawiki/corewmf/1.46.0-wmf.17+0 -8
mediawiki/coremaster+54 -27
mediawiki/coremaster+0 -8
Show related patches Customize query in gerrit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

[Please review project tags and subscribers when creating subtasks - thanks!]

Based on comparing https://caniuse.com/?search=WebP and https://caniuse.com/?search=tls+1.3

These versions of browsers support TLS 1.3 but not webp:

  • Safari 14 til 16
  • FF 63 til 65
  • Safari on iOS from 12.2 til 14

They are extremely small portion of requests. It seems like a straightforward choice to just simply serve the webp image directly. Do you have any concerns @AntiCompositeNumber ? Am I missing something obvious?

TIFFs (e.g. https://commons.wikimedia.org/wiki/Category:TIFF_files#/media/File:%D0%A1%D0%B0%D0%BD%D0%B4%D0%B0%D0%BB_%D0%AF%D0%93%D0%A1%D0%A5%D0%90.tif) work similarly: raster graphics thumbnailed in another format. However, TIFF is not web-safe at all, so serving these files directly is out of question. Thus we should have an option for serving full-size converted images. If we have this option, does serving WebP directly (and thus breaking those few browsers) come with any benefit?

(Also, when you write “many old browsers can't connect anymore”, you mean “can’t connect to Wikimedia sites”, but when you suggest serving WebP directly, you probably suggest that MediaWiki is changed to serve WebP directly. Third-party users may still support TLS 1.2 or even unencrypted HTTP to make older browsers work.)

Perhaps instead for the odd non-web format (which seems to include XCF and TIFF currently, begging the WebP question for a moment) we should only generate standard-size thumbnails, and the commons file interface should drop the "original-size-converted-to-PNG" option entirely; mediaviewer would need adjusting to request the largest-standard-size-smaller-than-original too. These aren't formats intended for images-for-display on commons (per https://commons.wikimedia.org/wiki/Commons:File_types#Images).

TIFFs (e.g. https://commons.wikimedia.org/wiki/Category:TIFF_files#/media/File:%D0%A1%D0%B0%D0%BD%D0%B4%D0%B0%D0%BB_%D0%AF%D0%93%D0%A1%D0%A5%D0%90.tif) work similarly: raster graphics thumbnailed in another format. However, TIFF is not web-safe at all, so serving these files directly is out of question. Thus we should have an option for serving full-size converted images.

For tiff, I'd go with not serving upscaled image, the 2x version won't be served and people will see 1x thumb instead.

If we have this option, does serving WebP directly (and thus breaking those few browsers) come with any benefit?

webp is considerably smaller than webp. e.g. https://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Myrlyn_1.0.0_screenshot.webp/1074px-Myrlyn_1.0.0_screenshot.webp.png is 150KB while the original of the same size is 60KB https://upload.wikimedia.org/wikipedia/commons/e/e1/Myrlyn_1.0.0_screenshot.webp

See T27611: Serve optimized WebP thumbnails as alternative to JPEG, PNG

(Also, when you write “many old browsers can't connect anymore”, you mean “can’t connect to Wikimedia sites”, but when you suggest serving WebP directly, you probably suggest that MediaWiki is changed to serve WebP directly. Third-party users may still support TLS 1.2 or even unencrypted HTTP to make older browsers work.)

1- I like theoretical problems and concerns but they don't belong here. Please bring some actual third party installations that really want to serve to old browsers to the point they are willing to serve HTTP requests (or older TLS or SSL versions) and open themselves to downgrade attacks.
2- Priorities of Wikimedia production always come before priorities of third parties. The engineering time is bought by donor money to serve interests of Wikimedia movement. If somewhere else wants to do something their own way, they are free to fork/write extension/whatever else.

Change #1247634 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[mediawiki/core@master] WebPHandler: Allow the original being served on the web

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

Change #1247634 merged by jenkins-bot:

[mediawiki/core@master] WebPHandler: Allow the original being served on the web

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

Change #1247671 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1247675 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] Media: Use previous step for non-standard width between steps and original

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

TIFFs (e.g. https://commons.wikimedia.org/wiki/Category:TIFF_files#/media/File:%D0%A1%D0%B0%D0%BD%D0%B4%D0%B0%D0%BB_%D0%AF%D0%93%D0%A1%D0%A5%D0%90.tif) work similarly: raster graphics thumbnailed in another format. However, TIFF is not web-safe at all, so serving these files directly is out of question. Thus we should have an option for serving full-size converted images.

For tiff, I'd go with not serving upscaled image, the 2x version won't be served and people will see 1x thumb instead. […]

If I understand correctly, the issue here is when a requested width exceeds the original. It seems to me the simplest fix that doesn't degrade UX more than needed, is to round down when we can't round up. We don't need to remove 2x entirely. This has the benefit of the logic remaining more stateless and straight-forward.

Removing "2x" would make a much larger sacrifice, and is harder to implement/enforce because it requires higher-level coordination (aware of srcset) and/or tolerate a new negative return somewhere lower down only if/when operating in this context. Whereas currently most of this logic in File.php and mw.util is agnostic about the higher-level srcset concept.

Change #1247671 merged by jenkins-bot:

[mediawiki/core@master] FileRepo: Clarify unit tests for steps and add tiff example

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

I like the idea. +2'ed the patch. Will backport all three (including my webp patch) tomorrow ish.

I've also got back my global interface right (I didn't renew it since I‌ didn't need it. Well, that obviously has changed). And I'm going through MediaWiki ns (ns=8) stuff to see what can be done. Since each one require a dedicated solution it's a bit a lot (there are 1000 of them) but the good news is that many wikis simply copy paste stuff. So for example 50 wikis have this:

background: url("//upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/11px-Loudspeaker.svg.png") center left no-repeat !important;

There is not an easy fix since !important overrides the background-size value but I assume I can squeeze it in the general background condition somehow :D Stay tuned.

First, fixing the ones that are already explicitly setting the width value so it'd be noop visually. Stuff like this: https://ps.wikipedia.org/w/index.php?title=%D9%85%DB%90%DA%89%D9%8A%D8%A7%D9%88%D9%8A%DA%A9%D9%8A:LoadingContent.js&diff=prev&oldid=361979 it'll be around 100 of them.

Change #1247675 merged by jenkins-bot:

[mediawiki/core@master] Media: Use previous step for non-standard width between steps and original

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

Change #1247723 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1247941 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[mediawiki/core@wmf/1.46.0-wmf.17] WebPHandler: Allow the original being served on the web

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

Change #1247944 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[mediawiki/core@wmf/1.46.0-wmf.18] WebPHandler: Allow the original being served on the web

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

Change #1247941 merged by jenkins-bot:

[mediawiki/core@wmf/1.46.0-wmf.17] WebPHandler: Allow the original being served on the web

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

Change #1247944 merged by jenkins-bot:

[mediawiki/core@wmf/1.46.0-wmf.18] WebPHandler: Allow the original being served on the web

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

Mentioned in SAL (#wikimedia-operations) [2026-03-04T10:17:55Z] <ladsgroup@deploy2002> Started scap sync-world: Backport for [[gerrit:1247941|WebPHandler: Allow the original being served on the web (T414805 T418745 T418346)]], [[gerrit:1247944|WebPHandler: Allow the original being served on the web (T414805 T418745 T418346)]]

Mentioned in SAL (#wikimedia-operations) [2026-03-04T10:19:59Z] <ladsgroup@deploy2002> ladsgroup: Backport for [[gerrit:1247941|WebPHandler: Allow the original being served on the web (T414805 T418745 T418346)]], [[gerrit:1247944|WebPHandler: Allow the original being served on the web (T414805 T418745 T418346)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-03-04T10:24:37Z] <ladsgroup@deploy2002> Finished scap sync-world: Backport for [[gerrit:1247941|WebPHandler: Allow the original being served on the web (T414805 T418745 T418346)]], [[gerrit:1247944|WebPHandler: Allow the original being served on the web (T414805 T418745 T418346)]] (duration: 06m 42s)

Change #1247723 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1250719 had a related patch set uploaded (by Reedy; author: Ladsgroup):

[mediawiki/core@REL1_45] WebPHandler: Allow the original being served on the web

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

Change #1250720 had a related patch set uploaded (by Reedy; author: Ladsgroup):

[mediawiki/core@REL1_44] WebPHandler: Allow the original being served on the web

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

Change #1250721 had a related patch set uploaded (by Reedy; author: Ladsgroup):

[mediawiki/core@REL1_43] WebPHandler: Allow the original being served on the web

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

Change #1250719 merged by jenkins-bot:

[mediawiki/core@REL1_45] WebPHandler: Allow the original being served on the web

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

Change #1250720 merged by jenkins-bot:

[mediawiki/core@REL1_44] WebPHandler: Allow the original being served on the web

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

Change #1250721 merged by jenkins-bot:

[mediawiki/core@REL1_43] WebPHandler: Allow the original being served on the web

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

Change #1251527 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_43] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1251528 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_43] Media: Use previous step for non-standard width between steps and original

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

Change #1251529 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_43] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1251530 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_44] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1251531 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_44] Media: Use previous step for non-standard width between steps and original

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

Change #1251532 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_44] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1251533 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_45] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1251534 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_45] Media: Use previous step for non-standard width between steps and original

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

Change #1251535 had a related patch set uploaded (by Reedy; author: Krinkle):

[mediawiki/core@REL1_45] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1251527 merged by jenkins-bot:

[mediawiki/core@REL1_43] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1251528 merged by jenkins-bot:

[mediawiki/core@REL1_43] Media: Use previous step for non-standard width between steps and original

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

Change #1251530 merged by jenkins-bot:

[mediawiki/core@REL1_44] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1251531 merged by jenkins-bot:

[mediawiki/core@REL1_44] Media: Use previous step for non-standard width between steps and original

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

Change #1251533 merged by jenkins-bot:

[mediawiki/core@REL1_45] FileRepo: Clarify unit tests for steps and add tiff example

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

Change #1251534 merged by jenkins-bot:

[mediawiki/core@REL1_45] Media: Use previous step for non-standard width between steps and original

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

Change #1251529 merged by jenkins-bot:

[mediawiki/core@REL1_43] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1251535 merged by jenkins-bot:

[mediawiki/core@REL1_45] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Change #1251532 merged by jenkins-bot:

[mediawiki/core@REL1_44] mediawiki.util: Prefer prev step over non-standard in adjustThumbWidthForSteps

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

Two of the patches from this task (and their backports to REL branches) have been reverted due to causing T419927: PNGs are being displayed at a too-low, blurry resolution:

I think the bug as written here is still resolved, though. If we want to reapply them, we should probably start a new task that better explains the problem they were trying to solve.

As I understand it, that patch was intended to allow serving standardized thumbnail sizes when a full size is requested for a file that we can't display directly, e.g. PDF or TIFF files. Files that we can display directly, such as PNG or JPG, should probably serve the original in this case.

Change #1275921 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[mediawiki/core@master] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1275921 merged by jenkins-bot:

[mediawiki/core@master] Media: Fallback to the largest standard size if an overly large one is requested

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

This comment was removed by Krinkle.

Change #1276731 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[mediawiki/core@wmf/1.46.0-wmf.24] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1276731 merged by jenkins-bot:

[mediawiki/core@wmf/1.46.0-wmf.24] Media: Fallback to the largest standard size if an overly large one is requested

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

Mentioned in SAL (#wikimedia-operations) [2026-04-23T16:20:36Z] <ladsgroup@deploy1003> Started scap sync-world: Backport for [[gerrit:1276731|Media: Fallback to the largest standard size if an overly large one is requested (T418745 T423895)]]

Mentioned in SAL (#wikimedia-operations) [2026-04-23T16:22:11Z] <ladsgroup@deploy1003> ladsgroup: Backport for [[gerrit:1276731|Media: Fallback to the largest standard size if an overly large one is requested (T418745 T423895)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-04-23T16:26:29Z] <ladsgroup@deploy1003> Finished scap sync-world: Backport for [[gerrit:1276731|Media: Fallback to the largest standard size if an overly large one is requested (T418745 T423895)]] (duration: 05m 53s)

Change #1277086 had a related patch set uploaded (by Reedy; author: Ladsgroup):

[mediawiki/core@REL1_45] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1277087 had a related patch set uploaded (by Reedy; author: Ladsgroup):

[mediawiki/core@REL1_44] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1277088 had a related patch set uploaded (by Reedy; author: Ladsgroup):

[mediawiki/core@REL1_43] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1277088 merged by jenkins-bot:

[mediawiki/core@REL1_43] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1277087 merged by jenkins-bot:

[mediawiki/core@REL1_44] Media: Fallback to the largest standard size if an overly large one is requested

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

Change #1277086 merged by jenkins-bot:

[mediawiki/core@REL1_45] Media: Fallback to the largest standard size if an overly large one is requested

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