Page MenuHomePhabricator

Media namespace links should allow fragments
Open, Needs TriagePublic


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:

Event Timeline

srishakatux added a subscriber: srishakatux.

@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 added a subscriber: Soda.

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

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