Images: New images get a link=… set whether or not they need it
Closed, ResolvedPublic

Description

Follow-on from bug 49596.

The insertion of a new image adds link=… whether or not it's been actively set away from the default.

Thus (in the example in bug 49596 comment 0) we get:

[[File:CV.03326.jpg|link=https://commons.wikimedia.org/wiki/File:CV.03326.jpg|right|framed|424x275px]]

… instead of:

[[File:CV.03326.jpg|right|framed|424x275px]]

… which is bad in terms of wikitext-user utility.


Version: unspecified
Severity: minor

Details

bzimport set Reference to bz49844.

This looks like a Parsoid issue:

<span typeof="mw:Image" ><a href="./File:VisualEditor-logo.svg" data-parsoid="{'a':{'href':'./File:VisualEditor-logo.svg'}}"><img src="http://vewiki/MediaWiki/images/thumb/1/12/VisualEditor-logo.svg/300px-VisualEditor-logo.svg.png" resource="./File:VisualEditor-logo.svg" width="300" height="105"></a></span>

serialises to:

[[File:VisualEditor-logo.svg|300x105px]]

Whereas

<span typeof="mw:Image" ><a href="./File:VisualEditor-logo.svg"><img src="http://vewiki/MediaWiki/images/thumb/1/12/VisualEditor-logo.svg/300px-VisualEditor-logo.svg.png" resource="./File:VisualEditor-logo.svg" width="300" height="105"></a></span>

(removed data-parsoid from <a> tag)

serialises to:

[[File:VisualEditor-logo.svg|link=File:VisualEditor-logo.svg|300x105px]]

Related URL: https://gerrit.wikimedia.org/r/70551 (Gerrit Change I75dbbfdd248a6f5696252ef3a2d7ca6ede0fa156)

  • Bug 49848 has been marked as a duplicate of this bug. ***

This is worked around (albeit with potentially a bit of a hack) in VisualEditor, so not so important now from VisualEditor's POV.

[Parsoid component reorg by merging JS/General and General. See bug 50685 for more information. Filter bugmail on this comment. parsoidreorg20130704]

I cannot reproduce this on latest master.

[subbu@earth lib] cat /tmp/img.html
<span typeof="mw:Image" ><a href="./File:VisualEditor-logo.svg"><img src="http://vewiki/MediaWiki/images/thumb/1/12/VisualEditor-logo.svg/300px-VisualEditor-logo.svg.png" resource="./File:VisualEditor-logo.svg" width="300" height="105"></a></span>
[subbu@earth lib] node parse --html2wt < /tmp/img.html
[[File:VisualEditor-logo.svg|300x300px]]

This should be fixed by https://gerrit.wikimedia.org/r/103082 (if it wasn't already fixed). Should be verified fixed by the VE team once this lands (and their local workaround reverted?).

This bug is fixed; opened bug 61560 for the VE team to revert their workaround hack.

Hm, maybe this only occurs with images from commons now? Can you confirm that, James? It would be helpful to see exactly what VE is giving to Parsoid for new images, and how you are indicating that the link is the default.

Hm, I note that the DOM spec describes "resource attribute on image" this way:

link to image resource page. TODO: what to use for images from commons?

I'm guessing this is the root of the problem. What is VE currently setting the resource attribute to, for images from commons?

Ok, from looking at the code I can confirm that the link= attribute should be suppressed iff the img[resource] attribute is equal to the a[href]. I'm guessing that autocommons is screwing with this?

mooeypoo and I tried to reproduce without success. the code looks correct: the link option is suppressed iff a[href] == img[resource]. Both of these should be local relative URLs, since the only way external images can be referenced is via instacommons (which provides local URLs for the image).

Change 119087 had a related patch set uploaded by Cscott:
Clarified the default link for image insertion.

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

Change 119087 merged by jenkins-bot:
Clarified the default link for image insertion.

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

Add Comment