Page MenuHomePhabricator

MediaViewer doesn't open when clicking magnify button on pages rendered by Parsoid
Closed, ResolvedPublic

Description

Background

Parsoid uses a different HTML structure for images than the legacy Parser originally did. This new Parsoid format generally uses pure CSS approach to display a "magnify" button (via an ::after pseudo-element), whereas in the legacy HTML there is a dedicated <div class=magnify> element in the caption.

MediaViewer supports both variants in mmv.bootstrap.js via the processThumb() function and just below it, the processParsoidThumb() function.

As part of debugging T422586, I noticed that 1) we process thumbnails for the "Parsoid" path even when using the legacy parser, and 2) the magnify button does not work when using a custom link.

Problem

As part of T394054, $wgParserEnableLegacyMediaDOM was removed and now Parsoid and the legacy Parser both use this new format.

In T329413, the new format was changed to bring back the dedicated <div class=magnify> element for cases where the thumbnail has a custom link.

[[File:Example.jpg|thumb|link=https://wikipedia.org]]

MediaViewer does not recognize the magnify link anymore as a result of this, because this was not part of Parsoid originally.

https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=8349168

MediaViewer does not open when clicking "Magnify" in the image caption.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The MediaViewer source makes reference to https://www.mediawiki.org/wiki/Specs/HTML#Media, where, as of writing (version 2.8.0) there is no mention of "magnify".

Should the spec be updated to include this?

Change #1276050 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/extensions/MultimediaViewer@master] Open MediaViewer with mw-file-magnify links

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

ABreault-WMF subscribed.
  1. we process thumbnails for the "Parsoid" path even when using the legacy parser

The naming there is historic and just refers to the new media structure, nothing Parsoid specific. Now that $wgParserEnableLegacyMediaDOM is removed, the legacy parser always emits that for thumbs.

Would processThumb and processLegacyThumb be preferable? It's a bit confusing between legacy parser and legacy media dom

The MediaViewer source makes reference to https://www.mediawiki.org/wiki/Specs/HTML#Media, where, as of writing (version 2.8.0) there is no mention of "magnify".

The spec currently says,

Note 3: The PHP parser adds a <a href="./File:Foo.jpg" class="internal sprite details magnify" title="View photo details"></a> element inside the <figure>. Parsoid adds this with css (see T329413 where, in some cases, the css implementation is insufficient and further development is needed).

That should be updated, yes

Change #1276050 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Open MediaViewer with mw-file-magnify links

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

Change #1287003 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/extensions/MultimediaViewer@master] Rename variables to reflect new reality

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

Change #1287040 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/extensions/MultimediaViewer@master] Add a test for recognizing thumbs with mw-file-magnify links

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

Change #1287003 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Rename variables to reflect new reality

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

Change #1287040 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Add a test for recognizing thumbs with mw-file-magnify links

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