5,349 Pages

With pure JS, we end up doing:

// For older browsers with lack of Object.keys()
if (!Object.keys) { Object.keys = function (object) { var keys = []; for (var key in object) { if (object.hasOwnProperty(key)) { keys.push(key); } } } }
$.getJSON('http://leagueoflegends.wikia.com/api.php?action=query&format=json', {
    //indexpageids: '', // Object.keys()
    titles: 'File:SonaSquare.png',
    prop: 'imageinfo',
    iilimit: 1,
    iiprop: 'url',
}).done(function(data) {
    mw.log('API result:', data);
    // undefined checks omitted for brevity
    var query = data.query;
    var id = Object.keys(query.pages)[0]; // Because titles only has one name.
    var url = query.pages[id].imageinfo[0].url;
    // Do something with url
    alert('URL:', url);
}).fail(function(error) {
    mw.log('API failed:', error);
});
Community content is available under CC-BY-SA unless otherwise noted.