Module talk:ExistNotRedirect

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Fix for Commons links[edit]

Per the great idea of Nardog at Wikipedia:Village pump (technical) § #ifexist and Commons, this template can be made to work with File: links!

I've gone ahead and done so in the sandbox, via these four commits:

Megadiff
Revision Diff Description
PermaLink/967117490 [1] If page to check is in File: namespace, check Media: so Commons links work
PermaLink/967117978 [2] Make it so Commons links can optionally not be counted via |forcefile=
What would possess someone to want to use this, I don't know, but to be safe . . .
PermaLink/967119638 [3] Make it so people always get back what they asked for. Essential for those doing e.g.:
[[{{ExistNotRedirect|File:SNice.svg}}|16px]] so they get , not 16px
PermaLink/967124319 [4] Improve error message, which was confusing before when link unparseable.

Please merge therefore Module:ExistNotRedirect/sandbox to Module:ExistNotRedirect, and Template:ExistNotRedirect/sandbox to Template:ExistNotRedirect, being careful, of course, to first remove the /sandbox in the #invoke on line 1. Psiĥedelisto (talkcontribs) please always ping! 11:30, 11 July 2020 (UTC)[reply]

Oh, I should probably ping both BrownHairedGirl, who did the awesome work of writing this module in the first place, and Nardog. Psiĥedelisto (talkcontribs) please always ping! 11:31, 11 July 2020 (UTC)[reply]

I feel like this should be achieved by changing if myPageTitle.exists then to if myPageTitle.exists or myPageTitle.file and myPageTitle.file.exists then. That way it would work in all languages. Nardog (talk) 11:43, 11 July 2020 (UTC)[reply]
Sample code. Feel free to revert to your version. Nardog (talk) 11:54, 11 July 2020 (UTC)[reply]
@Nardog: The test cases are still outputting the same, so I see no reason to. Thanks for helping out! Psiĥedelisto (talkcontribs) please always ping! 11:56, 11 July 2020 (UTC)[reply]
Thanks for the ping, @Psiĥedelisto.
This issue of using "Media:" to check for Commons files is one that I first encountered only a few days ago, when I was trying to figure out how to add maps to bilateral relations categories. I got it working at Template:Foo–Bar relations category/mapname, and am pleased with the result: 5,315 Foo–Bar relations categories now have a locator map.
It seems like a great idea to add it to this module, and the code looks fine to me. However, it would be best to see some testcases before going live. Please can you make some testcases?
Also, note that if this goes live, Template:ExistNotRedirect/doc will need to be updated. --BrownHairedGirl (talk) • (contribs) 11:49, 11 July 2020 (UTC)[reply]
@BrownHairedGirl: Regarding the test cases, way ahead of you! Template:ExistNotRedirect/testcases Would you like me to update the doc now? Usually I wait for the changes to be live so no one gets confused. Psiĥedelisto (talkcontribs) please always ping! 11:52, 11 July 2020 (UTC)[reply]
Thanks, @Psiĥedelisto. That looks great.
So I say it's ready to go live. And yes I agree that it's best to wait for the changes to be live before updating the /doc. --BrownHairedGirl (talk) • (contribs) 11:57, 11 July 2020 (UTC)[reply]
 Done Mdaniels5757 (talk) 18:37, 14 July 2020 (UTC)[reply]