Page MenuHomePhabricator

FileExporter: Provide an option/configuration to not render the "Export to Wikimedia Commons" button depending on categorization of the File
Open, Needs TriagePublic

Description

Currently the extension does a very simple check before rendering the button: the page exists, it's in the NS_FILE namespace, and user->isNewbie() is false. On the English Wikipedia this button should not be visible for files categorized in "All non-free media" or "Wikipedia files not suitable for Commons". For other languages these categories will likely be different. For the Farsi Wikipedia, they actually disable it through Javascript for certain categories.

This would help with the possibility of a user clicking the button and being disappointed when FileImporter gives an error because the file doesn't qualify import in to Commons.

Alternatively, if there were a way to determine if FileImporter would decline the image and omit the button in that case altogether, that could work too.

Event Timeline

Addshore subscribed.

Sounds like a pretty good usecase

Based on https://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Common.js#L-449 and https://en.wikipedia.org/wiki/MediaWiki_talk:Common.js#Export_to_Wikimedia_Commons_button simply skipping the button when a page is in a category might be the only needed change.
This can easily be done in the existing code by checking getCategories on the page in question.

What would make the most sense for configuration?

  • PHP config option? set via mediawiki-config and deployed etc?
  • Some on wiki configuration?

Well, on further consideration I almost wonder if it wouldn't make sense to use the exact same check that FileImporter uses? In this way the same settings are used for both (ex: English language Wikipedia FileImporter settings), and the experience is consistent without a risk of settings being more/less restrictive on one end of the experience vs. the other. I haven't looked at the FileImporter code, but it may be as simple as a copy/paste and making sure it's pointing at the correct configuration settings?

If that's not feasible/too complex, I'd use a similar config method as FileImporter just to keep the setup experience similar for users.

Listing out the categories onwiki in a MediaWiki namespace page is probably more flexible for wikis with non-free media, but a PHP config seems fine too.