Talk:Snippets/Direct imagelinks to Commons
Add topicSecure server
[edit]Is it still necessary to include checks for the secure server? --Locos epraix (talk) 08:16, 8 March 2012 (UTC)
MV compatiblity
[edit]I've suggested here a code improvement[1] (@Krinkle: -) --Perhelion (talk) 11:50, 8 August 2014 (UTC)
User language?
[edit]I oppose this change by He7d3r, as I've set my language properly on Commons and find the 'uselang' parameter quite annoying. --Ricordisamoa 23:17, 13 January 2015 (UTC)
- @Ricordisamoa: I was just tying to keep the gadget code central, instead of maintaining each fork of the code separately (which does not scale!). See also Talk:Snippets#Make it possible to import the snippets directly. Helder 19:05, 10 July 2015 (UTC)
Reverted by Krinkle. --Ricordisamoa 14:11, 28 July 2015 (UTC)
MMV compatibility II
[edit]@He7d3r, Krenair, Jdforrester (WMF), and Krinkle: MultiMediaViewer is enabled by default. If I enable this gadget on my home wiki, it doesn't work. I have to disable MMV first to make this gadget work. It isn't hard for experienced users, but for beginners it is almost impossible to find out, how to make this gadget work. They just try to enable it to see its effect, they don't see any effect (because of enabled MMV) and they disable it back. Could you somehow force the direct link to Commons over MMV if users enable this gadget (so it is sure thay want to use it)? --Dvorapa (talk) 19:30, 25 January 2016 (UTC)
- @Dvorapa: I don’t know if anything changed in the pat six years, but now it works as I’d expect it: if I open the link directly in whatever way (opening in new tab, dragging the link to the URL bar etc.), it goes directly to Commons. And so does it if I open MediaViewer and click the big blue button on its toolbar, as MV’s default behavior is to skip the local description page. Just because I never want to see the local description page, I might want to use MediaViewer. Since on most wikis most if not all files are from Commons, MediaViewer would be almost useless if it worked only with local files. —Tacsipacsi (talk) 09:17, 5 September 2022 (UTC)
Broken when the link is different when encoded
[edit]A user reported this being broken as apparently this now only works when the URL doesn't have characters that needs to be encoded in the URL so I applied this as attr href is decoded while localBasePath is in encoded space. −Ebrahimtalk 08:33, 13 February 2026 (UTC)
Added compatibility with current MW
[edit]Hi. It seems like a new version was rolled out and now links start with a local domain (rather than with a path like `/wiki/`). I've replaced it with a fixed version. @Ebrahim: I've included your fix too. Nux (talk) 09:11, 16 April 2026 (UTC)
- @Krinkle please bring back my version. Re-creating vars on each content load is suboptimal. Using regexp is suboptimal. Nux (talk) 15:07, 16 April 2026 (UTC)
- The final version is at: pl:MediaWiki:Gadget-Direct-link-to-Commons.js Nux (talk) 15:20, 16 April 2026 (UTC)
- @Nux: Your version introduces bugs due to matching too loosely, sometimes failing to match, or matching too often.
- You can find one of these bugs on Russian Wikipedia, where it fails to activate due to missing URL encoding.
- On pages like pl:Wikipedysta:Theeducatedsparrow, there is a different bug causing it to be active when it should not, thus breaking the link for a file that is not on Commons (404 Not Found).
- Can you have a look at these? Krinkle (talk) 10:54, 17 April 2026 (UTC)
- Oh yes, I forgot local files are still on the upload domain. And escaping fixed as well. Thanks for the test/review. Should be all good now... unless you see some other problems? Nux (talk) 19:49, 17 April 2026 (UTC)
- @Krinkle: Your version is not compatibile with zhwiki.--Dabao qian (talk) 19:27, 22 August 2026 (UTC)
Consider a server-side solution
[edit]This snippet is quite cumbersome, and as the Parsoid adaptation further proved, also somewhat fragile. Doing URL rewrites in client-side JavaScript doesn't feel like the right place for this — it should be handled server-side. Is there an existing Phabricator ticket for this? Od1n (talk) 16:59, 27 June 2026 (UTC)