Page MenuHomePhabricator

Inconsistent use of href parameter and selflink mw-selflink classes between plain links and links in images
Open, Needs TriagePublic

Description

Standard MediaWiki behavior: When a link is rendered from wikitext and the user is on the same page that the link is referencing the [a] element is rendered without a href attribute and with the classes selflink mw-selflink. This is a sensible way and gives styling opportunities.

However if File: or Image: is used with the link-parameter the same does not apply. The link is rendered with a href attribute and without the classes selflink mw-selflink.

Could you please make the behavior consistent betweens text links and image links and use selflink mw-selflink also for File: and Image:?

Event Timeline

Aklapper renamed this task from Inconsistent behavior regarding plain links and links in images to Inconsistent use of href parameter and selflink mw-selflink classes between plain links and links in images.May 9 2023, 1:14 PM

@Arlolra could this be addressed in your media work? This is also perhaps something that could be done in @ihurbain's redlink pass in Parsoid.

@Arlolra could this be addressed in your media work?

Parsoid currently doesn't add self-links at all, which is T69486. We can do it as part of that work.

My tests as of today indicate that, on the legacy parser, we do add the selflink mw-selflink classes to image pages - see for instance https://test.wikipedia.org/w/index.php?title=File:Appenzellerweg.jpg&useparsoid=0. Parsoid is not handling these right now (but T69486 is in progress), but it's also handling them consistently.
I am hence tentatively declining this issue - if more information/test cases are available, please feel free to reopen!

Hi @ihurbain, thank you for your consideration! We would kindly like to take you up on your offer to reopen this issue. The test you have constructed is not the use case we are talking about.

What we would like to see - preferably in Parsoid for future use - is images with the link attribute being handled like links.

Specifically, let's assume a test page with the route /wiki/Testpage. If an internal link to /wiki/Testpage is on /wiki/Testpage itself then the link is rendered with the selflink mw-selflink classes. If on /wiki/Testpage there's an image with the link attribute pointing to /wiki/Testpage itself then the outer a-element is NOT rendered with selflink mw-selflink.

We consider this inconsistent behavior. Because while this is still primarily an image it is also wrapped inside an a-element and therefore can and - in our opinion for consistency reasons - should be treated like a link element. This would mean that the outer a-element for an image on /wiki/Testpage with the link attribute linking to this exact page /wiki/Testpage should also be treated like a link element and have the selflink mw-selflink classes.

What we are not talking about is a user visiting a File: link such as wiki/File:Somefile.

The syntax to test is [[File:Somefile|link=Testpage]] on Testpage

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

[mediawiki/core@master] [WIP] Recognize selflinks in the media link option

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

The patch above is pretty much what it would take to do this in the legacy parser. But note that the |link= option doesn't get turned into a redlink either so the problem is a bit more general.

On the Parsoid side, the current redlink / selflink post-processing pass querySelects mw:WikiLinks, which isn't applied inside the media structure. We could add it but whether that's semantically correct needs clarification. Alternatively, we could select links to apply the class based on hrefs matching a pattern.