Page MenuHomePhabricator

[Spike] Explore how a change to our thumbnail scale affects the app
Closed, ResolvedPublicSpike

Description

See Slack thread here.

In service of hypothesis 5.4.7, SRE would like reduce the variations in sizes we request from the server.

The standard 8 MediaWiki thumbnail sizes are:

20, 40, 60, 120, 250, 330, 500, 960

This task is to create a prototype that:

  1. Modifies our thumbnail generation code so that it always chooses one of the standard 8 sizes as listed above.

For example, if we have code that requests the small size (note we double for retina devices, so this requests 240 instead of 120), we want to scale it up to the nearest MediaWiki standard size above, in this case it would be 250.

  1. Kick off an Experimental build and have QA + Design note any reduction in quality for images in the app, especially for larger images like the 13-inch iPad gallery view. Also note any increased image load times (in case our new logic causes us to request many more larger images).

Gather findings into a list of any additional thumbnail sizes we feel are necessary to maintain the quality of the app. We will need to balance image quality, image load times, and any additional network data that this change might cause.

Event Timeline

Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptDec 9 2025, 10:23 PM
Tsevener renamed this task from [Spike] Explore how our a change to our thumbnail scale affects the app to [Spike] Explore how a change to our thumbnail scale affects the app.Dec 11 2025, 5:30 PM

I have created an experimental build (TestFlight Experimental 7.8.9 (297)) to limit thumbnail requests to these standard 8 sizes:

20, 40, 60, 120, 250, 330, 500, 960

Moving to Blocked while we consider next steps.

I discovered some non-standard sizes that originate from the PCS endpoints:

https://en.wikipedia.org/api/rest_v1/page/mobile-html/Cat
https://en.wikipedia.org/api/rest_v1/page/media-list/Cat

You will see references to sizes like 1280px and 640px in those responses. For this experimental build I am overwriting these client-side, but the preferred approach would be for us to fix it in the endpoint.

This work is in the adjust-thumbnails branch.

media-list endpoint needs fixing. I will check and make sure to fix it but on the mobile-html endpoint, almost all images I'm seeing are in standard sizes:

grafik.png (446×1 px, 117 KB)

Is there anything broken?

@Ladsgroup For something like the Cat mobile-html, I see in the view source nonstandard sizes like:

<span data-resource="./File:Wild-domestic-hybrid_cat_skulls.png" data-src="//upload.wikimedia.org/wikipedia/commons/thumb/2/21/Wild-domestic-hybrid_cat_skulls.png/320px-Wild-domestic-hybrid_cat_skulls.png" data-decoding="async" data-data-file-width="585" data-data-file-height="678" data-data-file-type="bitmap" data-height="371" data-width="320" data-srcset="//upload.wikimedia.org/wikipedia/commons/thumb/2/21/Wild-domestic-hybrid_cat_skulls.png/480px-Wild-domestic-hybrid_cat_skulls.png 1.5x" data-class="mw-file-element pcs-widen-image-override" data-data-file-original-src="//upload.wikimedia.org/wikipedia/commons/thumb/2/21/Wild-domestic-hybrid_cat_skulls.png/250px-Wild-domestic-hybrid_cat_skulls.png" class="mw-file-element pcs-widen-image-override pcs-lazy-load-placeholder" style="width: 320px;">

Writing up some notes on where the larger sizes were found:

3840:
This is rarely used, from what I can tell we only use it as a max-cap in case the Explore feed's Picture of the Day tries to request an even larger size.
Source

2560:
This is used for the Explore feed's Picture of the Day card:
Source

1280:
This is used in more places.

  • Saved articles tab thumbnails (but only if the layout expands on device enough so that the image view size is > 300).
  • Article lead/header image
  • Some of our explore feed cards (featured article, related pages, random article, continue reading) images
  • Gallery images (gallery is seen when tapping POTD explore card and any images in the article view)

Note that all of these areas will now request 960 in the build, so we should check these areas for a dip in quality.

@Ladsgroup For something like the Cat mobile-html, I see in the view source nonstandard sizes like:

<span data-resource="./File:Wild-domestic-hybrid_cat_skulls.png" data-src="//upload.wikimedia.org/wikipedia/commons/thumb/2/21/Wild-domestic-hybrid_cat_skulls.png/320px-Wild-domestic-hybrid_cat_skulls.png" data-decoding="async" data-data-file-width="585" data-data-file-height="678" data-data-file-type="bitmap" data-height="371" data-width="320" data-srcset="//upload.wikimedia.org/wikipedia/commons/thumb/2/21/Wild-domestic-hybrid_cat_skulls.png/480px-Wild-domestic-hybrid_cat_skulls.png 1.5x" data-class="mw-file-element pcs-widen-image-override" data-data-file-original-src="//upload.wikimedia.org/wikipedia/commons/thumb/2/21/Wild-domestic-hybrid_cat_skulls.png/250px-Wild-domestic-hybrid_cat_skulls.png" class="mw-file-element pcs-widen-image-override pcs-lazy-load-placeholder" style="width: 320px;">

That's fine. It's one image from the total of twenty that is not following the standard sizes. The logic in thumbnail steps allows in edge cases to not use rounding up. In this case, it's probably not needed and I should investigate and fix it but the assumption that every single image will be served with standard sizes is also not correct. We have all sorts of edge cases but they should be quite small.

It's worth noting here, I think, that per T412971 we're likely adding 1280, 1920, 3840 to the set of standard sizes (so if you want to use them appropriately in the iOS app, that should be good).

I did a bit of check where https://en.wikipedia.org/api/rest_v1/page/media-list/Cat is coming from and it's PCS. I'm talking to CTT to fix it.

It's worth noting here, I think, that per T412971 we're likely adding 1280, 1920, 3840 to the set of standard sizes (so if you want to use them appropriately in the iOS app, that should be good).

I already added these sizes to the documentation in mediawiki.org and exemption from rate limit. Only thing left is thumb steps mw config.

FTR, the PCS‌change is now deployed, caches need to expire but anything from PCS‌ should be serving standard sizes instead. Should we close this?