Page MenuHomePhabricator

Media namespace links should allow fragments, e.g. for linking to specific page of PDF files
Open, Needs TriagePublic

Description

e.g. [[media:Foo.pdf#page=3]] should link to third page (assuming pdf client supports that). Currently the fragment identifier is stripped [If in legacy fragment mode, that would also break the link, but that's a separate issue]

Anyone wanting to fix this, you probably need to:

Details

Event Timeline

srishakatux subscribed.

@Bawolff I've a newbie question - this task would require all changes to MediaWiki core, right?

@Bawolff I've a newbie question - this task would require all changes to MediaWiki core, right?

Mostly yes

Parsoid's Wikimedia\Parsoid\Wt2Html\TT\WikiLinkHandler::linkToMedia() would probably have to be updated too, but I'm not sure if the person who does this task would have to do that part too

Soda subscribed.

Trying to figure stuff out :)

@Bawolff, I looked into this, looks like the Linker::makeMediaLinkFile() function receives an already stripped/sanitised output from includes/parser/Parser.php:2607, the culprit probably being the MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title, $options ) call at line no 3900 beyond which I'm having some difficulty in understanding what the code does... Could you provide some hints as to how I should proceed ?

So Media links are supposed to link directly to a file, where image links link to the file's description page. (In wikitext, difference between [[media:Example.svg]] and [[:File:Example.svg]] )

Right now the parser passes in a title that links to the image description page. We used findFile to get the url to the actual file (as opposed to its description page). The problem is, that in doing that we throw away the fragment, which we want to keep.

Change 577615 had a related patch set uploaded (by Sohom Datta; owner: Sohom Datta):
[mediawiki/core@master] Allowed Media namespace links to use fragments

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

@Bawolff I've submitted the patch, could you take a look :)

Removing task assignee due to inactivity as this open task has been assigned for more than two years. See the email sent to the task assignee on August 22nd, 2022.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome!
If this task has been resolved in the meantime, or should not be worked on ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

@Bawolff I've submitted the patch, could you take a look :)

I apologize, I missed this comment when you originally made it. I imagine its been pretty disheartening to have this just sit here. Sorry about that.

@Soda: Removing task assignee as this open task has been assigned for more than two years - See the email sent on 2025-05-22.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome!
If this task has been resolved in the meantime, or should not be worked on by anybody ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

Change #577615 abandoned by Hashar:

[mediawiki/core@master] Linker: Allowed Media namespace links to use fragments

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

Change #577615 restored by Thcipriani:

[mediawiki/core@master] Linker: Allowed Media namespace links to use fragments

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

matmarex renamed this task from Media namespace links should allow fragments to Media namespace links should allow fragments, e.g. for linking to specific page of PDF files.May 14 2026, 6:47 PM