https://bugzilla.wikimedia.org/show_bug.cgi?id=29640
Web browser: ---
Bug #: 29640
Summary: need an easy way to see if a filename is in use via
the API (including InstantCommons)
Product: MediaWiki
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: API
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
Classification: Unclassified
Right now, it seems that the only way to check if a file name is already in use
on Wikipedia is to do api.php?action=query&titles=<imageTitle>&prop=imageinfo
Then you have to do the following awkward test on the results:
if ( !data.query.pages[-1] || data.query.pages[-1].imageinfo) { // image exists
The reason for this is that the API returns a page id for a local image, or -1
for no image. However, it also returns -1 if it finds an image through
InstantCommons.
It would be nice if there was a simpler way to do this. Maybe
prop=filenameinuse that just returns true or false. There are two uses for
this: 1) Making sure that an image someone wants to use for something on-wiki
actually exists before they use it. 2) Making sure that uploading scripts don't
upload over other files.
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l