Page MenuHomePhabricator

Image Browsing: Ensure all images fetched at appropriate display density
Closed, ResolvedPublic3 Estimated Story Points

Description

Ensure that images are fetched at the appropriate resolution for the device's display density, in both the image carousel and the detail view.

Context

During prototype code review (https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ReaderExperiments/+/1196969), it was noted that the prototype generated thumbnail URLs by manipulating image.src without consulting image.srcset, which includes 2x density URLs. This could result in fetching blurrier images than necessary, especially at small physical sizes on high-density displays.

As we scale to production (T410786), this applies to:

  • Carousel thumbnails (Minerva): need to display sharp thumbnails at the correct density
  • Detail view (MMV beta viewer): the PoC includes thumbnailGuessing.js for responsive thumbnail URL rewriting, but should also account for srcset and known pre-rendered sizes

Requirements

  • Ensure copying of both src and srcset (2x) attributes when reusing a live thumbnail, to ensure the proper density variant is loaded and displayed
  • Ensure chosen sizes for images URLs are likely to be pre-rendered to avoid on-demand thumbnail generation
    • either by reusing existing thumbnail URLs produced from the PHP side,
    • or by sending the 1x-density URL into mw.util.parseImageUrl() + mw.util.adjustThumbWidthForSteps() -> info.resizeUrl() to match the PHP-side stepping logic

Event Timeline

egardner triaged this task as Medium priority.Oct 29 2025, 4:54 PM
Krinkle renamed this task from Image Browsing (post-MVP): use srcset to get thumbnail URLs at 1.5x and 2x density to Image Browsing (post-MVP): use srcset to get thumbnail URL at 2x density.Feb 16 2026, 5:09 PM
Krinkle subscribed.
egardner renamed this task from Image Browsing (post-MVP): use srcset to get thumbnail URL at 2x density to Image Browsing: Ensure all images fetched at appropriate display density.Feb 24 2026, 11:53 PM
egardner updated the task description. (Show Details)
bvibber updated the task description. (Show Details)
HSwan-WMF set the point value for this task to 3.Mar 31 2026, 4:51 PM

Quick survey of carousel + mmv beta state:

  • Carousel images are *widlly* too low resolution, especially when heavily cropped
  • images loaded into the viewer seem to correctly account for display density in their thumbnail selection and give a nice sharp image

Poking at the carousel confirms that we're copying the src but not the srcset so it's pulling the 1x density version for the inline thumbnail, and in some cases we're blowing that up to our carousel squares so it gets even blurrier than you'd start with from being the wrong density.

Copying the srcset as well should significantly improve things there by doubling the image density, while actually improving the intended behavior of reusing the same bitmaps that are being loaded in the body content.

Change #1275527 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/MultimediaViewer@master] [Image Carousel] Use correct display density for thumbnails

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

Change #1276064 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/extensions/MultimediaViewer@master] [Image Carousel] Add mapForCarousel test coverage

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

Change #1275527 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] [Image Carousel] Use correct display density for thumbnails

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

Assuming this task is about the MediaViewer code project, hence adding that project tag so other people who don't know or don't care about team tags can also find this task when searching via projects or looking at workboards. Please set appropriate project tags when possible. Thanks.