Page MenuHomePhabricator

Image carousel full-screen viewer captions depend on the image's section collapse status
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Load https://en.wikipedia.org/wiki/Titan_(moon) on your mobile device
  • Click on the Christiaan Huygens painting in the carousel and check the caption, then exit
  • Hide/unhide the section titled "Discovery and naming"

What happens?:
When the section is hidden/collapsed, captions for the images in that section are not shown in the full-screen viewer.

What should have happened instead?:
Captions should be shown regardles of the section collapsed/uncollapsed status.

Other information
First reported in this thread on enwiki: https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(policy)#c-Ponor-20260605150000-CaptainEek-20260605054300

Tested in Firefox Beta for Android and Chrome for Android; also on desktop with Minerva skin and all sections collapsed.

Event Timeline

@Ponor thanks for creating the ticket and sorry to hear you're still encountering this issue now that we're in beta. I haven't been able to reproduce the issue so will tag in QA help.

SherryYang-WMF lowered the priority of this task from High to Medium.

Reproduced

The bug is specific to the legacy-parser mobile pipeline, which is why this was difficult to replicate.

The original bug report, from the RFC page, targeted testwiki:Triton (moon). Testwiki renders that page with the legacy parser, while enwiki article pages use Parsoid read views. The bug only occurs on legacy-parser output.

Steps to reproduce

  1. Visit https://test.wikipedia.org/wiki/Triton_(moon)?useparsoid=0 in mobile view (on a phone, via DevTools mobile emulation, or by appending &mobileaction=toggle_view_mobile). Note: the Minerva skin alone (useskin=minerva) is not enough — the lazy-image transform only runs in mobile view. Viewport size and section collapse state don't matter, but mobile view does.
  2. Click the first image in the carousel (the William Lassell portrait) to open the viewer.

Expected: You would expect the caption under the in-article thumbnail to appear ("William Lassell, the discoverer of Triton");
Actual: The viewer falls back to the File description ("British astronomer William Lassell (1799–1880)").

If you instead force parsoid (via https://test.wikipedia.org/wiki/Triton_(moon)?useparsoid=1), you'll see the correct caption used at all times.

Why does this happen

  1. On legacy-parser output, MobileFormatter's LazyImageTransform replaces below-fold images with <span class="lazy-image-placeholder"> — there is no <img> in the DOM. (Parsoid pages get NativeLazyImageTransform instead, which keeps a real <img loading="lazy">, so they're unaffected.)
  2. MMV's bootstrap scans the page for thumbnails at DOM-ready. Placeholders are handled by processLegacyThumb() (added for T427542).
  3. That path finds captions via findLegacyCaption(), which only understands the pre-wgParserEnableLegacyMediaDOM=false markup: $link.closest( '.thumb' ) / .thumbcaption. Modern media DOM (<figure typeof="mw:File/Thumb"> + <figcaption>) has no .thumb class, so the container lookup comes up empty and the caption falls back to $link.prop( 'title' )undefined.
  4. With LightboxImage.caption undefined, the viewer header falls back to the file name.

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

[mediawiki/extensions/MultimediaViewer@master] Find captions for MobileFrontend lazy-load image placeholders

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

Change #1307001 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Find captions for MobileFrontend lazy-load image placeholders

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

Fix was confirmed on beta clusters, and a follow-up bug was filed T432038.
For a production check, we can check Italian wiki on Wednesday, July 15th. Here are a few itwiki examples to check before resolving this ticket:

Example 1: Tritone_(astronomia)

selected imageparsoid (?useparsoid=1)legacy parser (?useparsoid=0)
T428648_itwiki_Tritone(astronomia)_Storia_delle_osservazioni_1.png (680×1,470 px, 401 KB)
T428648_itwiki_Tritone(astronomia)_parsoid_1.png (682×1,468 px, 980 KB)
T428648_itwiki_Tritone(astronomia)_legacy_parser_1.png (682×1,474 px, 740 KB)

Example 2: Tritone_(astronomia)

selected imageparsoid (?useparsoid=1)legacy parser (?useparsoid=0)
T428648_itwiki_Tritone(astronomia)_Storia_delle_osservazioni_2.png (676×1,472 px, 467 KB)
T428648_itwiki_Tritone(astronomia)_parsoid_2.png (678×1,478 px, 524 KB)
T428648_itwiki_Tritone(astronomia)_legacy_parser_2.png (682×1,472 px, 448 KB)

Example 3: Italia

selected imageparsoid (?useparsoid=1)legacy parser (?useparsoid=0)
T428648_itwiki_Italia_Storia.png (748×976 px, 486 KB)
T428648_itwiki_Italia_parsoid.png (750×1,334 px, 791 KB)
T428648_itwiki_Italia_legacy_parser.png (750×1,330 px, 555 KB)

https://it.wikipedia.org/wiki/Italia?useparsoid=1#/media/File:Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg

Notice how the top caption, which is supposed the be from the local wiki, is not in Italian but in English.
Similar issue in the screenshots above, though you seem to have it in reverse: Italian with Paranoid.

Is this a known thing?

Hi @Ponor — thanks for flagging this; it's a real bug, distinct from the one fixed above but with the same underlying reason.

The Mona Lisa image on Italia is placed by the {{Doppia immagine verticale}} template, which wraps each image in its own table-like div markup:

<div class="thumb">
  <div class="thumbinner">
    <!-- block for the first image -->
    <div class="tsingle">
      <div class="thumbimage">
        <span typeof="mw:File">
          <a class="mw-file-description" ...>
            <img ...> <!-- the image we want -->
          </a>
        </span>
      </div>
      <div class="thumbcaption"><!-- caption for this image --></div>
    </div>
    <!-- blocks for subsequent images continue -->
  </div>
</div>

Media Viewer's caption detection doesn't currently understand this arrangement (it knows the standard figure/figcaption markup, galleries, and infoboxes), so it finds no local caption and falls back to the file description from Commons — which for this file happens to be in English.

This particular case is broken on both parsers, since the wrapper markup comes from the template itself; which parser shows a given symptom on a given page just depends on which markup pattern that page's templates emit.

I will post a patch shortly that handles this pattern — with it, your example picks up "Monna Lisa di Leonardo" as expected.

Templates across wikis present images and captions in a lot of inconsistent, ad-hoc markup, so we won't be able to cover 100% of cases. Wherever the image–caption association is ambiguous (e.g. several images sharing one caption block), we deliberately show the file description rather than risk attaching the wrong caption.

But concrete reports like this one help us cover more real-world use cases, so please keep them coming (in a new ticket if this one is closed).

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

[mediawiki/extensions/MultimediaViewer@master] Find captions for images in legacy multi-image template markup

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

Test wiki created on Patch demo by EGardner (WMF) using patch(es) linked to this task:
https://76ef8d2131.catalyst.wmcloud.org/w/

Ok, patch is posted and a new patchdemo has been set up to verify the fix.

The Triton article we were looking at earlier has a good {Multiple image} example (similar to the issue on itwiki that @Ponor raised above): go to the section on Physical Characteristics and look at the multi-image block with a pie-chart and a relative size graphic stacked on top of one another (each image has its own unique caption below).

  • Live on enwiki (current behavior) -- each image uses the Commons file description
  • Patched on patchdemo (proposed fix) -- each image shows the caption as it appears in the article

I'm moving this to the current sprint so we can code review the new patch.

The non-localized caption bug is an existing bug shown on mobile and desktop versions, like this infobox image (https://it.wikipedia.org/w/index.php?title=Tritone_%28astronomia%29#/media/File:Triton_(moon).jpg). The captions were placed outside the <figure> element rather than inside the <figcaption>. Related bug: T429839: Image browsing: MMV doesn't display picture captions from Infobox

Change #1311516 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Find captions for images in legacy multi-image template markup

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

Checked the patch demo https://76ef8d2131.catalyst.wmcloud.org/wiki/Italy?mmvBeta=1#/media/File:Etruscan_Painting_1.jpg

Image has the caption in the articleThe img caption is displayed in the Beta MMV
Screenshot 2026-07-28 at 6.02.16 PM.png (347×755 px, 207 KB)
Screenshot 2026-07-28 at 6.07.04 PM.png (372×778 px, 256 KB)

Testing Note: Added to the list of fixes to be tested in production

Test wiki on Patch demo by EGardner (WMF) using patch(es) linked to this task was deleted:

https://76ef8d2131.catalyst.wmcloud.org/w/