https://bugzilla.wikimedia.org/show_bug.cgi?id=29640
--- Comment #2 from Brion Vibber <[email protected]> 2011-06-29 19:09:52 UTC --- I think the issue here is that imageinfo results shouldn't really be returned associated with a *page id* to begin with, as there may or may not be a local wiki page associated with the file. When querying info on multiple images at once, you seem to end up with a series of negative indexes -1, -2, etc: http://en.wikipedia.org/w/api.php?action=query&titles=File:North_Caucasus_topographic_map-fr.svg|File:Caucasus_Region_26-08-08.PNG&prop=imageinfo&format=jsonfm Now there may just not be a good alternate way to fit this into the output format of the highly page-centric query actions, but it feels kinda awkward. The advantage of it is that you *can* extend it easily from querying one file to querying multiple files since you can iterate over the same structure; but you need to know that the returned page ids will often be useless (for instance you can't save that -2 page id and use it in another lookup to get other info about the image, you need to use the title). What I usually do rather than hardcoding a -1 check (unsafe!) is to simply iterate over the collection, knowing it may contain either 0 or 1 items, and that the 1 item may or may not actually have image info to return: var imageinfo = false; if (data && data.pages) { $.each(data.pages, function(i, page) { if ('imageinfo' in page) { imageinfo = page.imageinfo; } }); } if (imageinfo) { // do something with it } else { // didn't find a matching image } This is then fairly easy to extend to handle multiple lookups; as you go through each row check its title to know which one you're dealing with. -- 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
