Page MenuHomePhabricator

Gallery does not allow lowercase "center" "left" or "right" as a caption for a gallery image
Open, MediumPublic

Description

This was initially reported as a false linter error on T266406 but further debugging revealed that Parsoid and Gallery are "eating" the words left, center or right (which make no sense anyway in the context of a Gallery image). Parsoid and Gallery provides a default halign value of none which when followed with a left, center or right word is parsed as an alignment, instead of passing through. These words get detected early on as an halign values and are consumed - so no longer available as a caption. They are also seen as a duplicate alignment parameter and flagged as a bogus parameter which the linter finds and reports erroneously.
The following wikitext demonstrates the issue:

<gallery>
File:Foobar.jpg|left
File:Foobar.jpg|notaleft
</gallery>

Event Timeline

For clarification, in case people are looking at this without context: Sometimes editors use "Center" as the caption for a gallery image, typically for an image showing the central area of buildings in a municipality. That caption is erroneously hidden by the MediaWiki software. It should be displayed.

Jonesey, this is a bug, and it will be fixed, not put off for years. It was
just more than a Linter bug, which is what I am focussing on, and after
debugging it, I determined that the problem occurs fairly early in the
parsing stages far removed from the Linter and is going to be tricky to
fix. I confirmed with my team mates that we will not deem this an annoying
quirk that we ignore, but fixing it was outside the scope of my current
tasks. I'll keep an eye on this task. Thanks for the additional insight as
to how editors might use Center more often than one might imagine.
Best,
Shannon

Arlolra renamed this task from Gallery does not allow "center" "left" or "right" as a caption for a gallery image to Gallery does not allow lowercase "center" "left" or "right" as a caption for a gallery image.Aug 24 2021, 3:14 PM

This bug may have been fixed at some point. I am seeing proper behavior, with no Linter errors reported, with the following code:

<gallery>
File:Foobar.jpg|left
File:Foobar.jpg|Left
File:Foobar.jpg|notleft
File:Foobar.jpg|center
File:Foobar.jpg|Center
File:Foobar.jpg|right
File:Foobar.jpg|Right
</gallery>

https://en.wikipedia.org/w/index.php?title=User:Jonesey95/sandbox2&oldid=1056627659

This bug may have been fixed at some point.

Nah, T266406 fixed some of it but it's still an issue

See the captions aren't rendered here, https://en.wikipedia.org/api/rest_v1/page/html/User:Jonesey95%2Fsandbox2/1056627659

And the lint is lost because it's considered a valid option {"ck":"left","ak":"left"} much like T214601,

> php bin/parse.php --restURL https://en.wikipedia.org/api/rest_v1/page/html/User:Jonesey95%2Fsandbox2/1056627659 --linting

<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-parsoid='{"dsr":[0,206,9,10]}' data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;" data-parsoid="{}"><div class="thumb" style="width: 150px; height: 150px;" data-parsoid="{}"><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"120x120px"},{"ck":"left","ak":"left"}]}'><a href="./File:Foobar.jpg" data-parsoid="{}"><img resource="./File:Foobar.jpg" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="240" data-file-height="28" data-file-type="bitmap" height="14" width="120" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, //upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"14","width":"120"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></div><div class="gallerytext" data-parsoid="{}"></div></li>
...