This is a test page. Anyone is free to use the code or examples on this page if they're at all helpful.
For a full list of test pages on the Mathmagician Wiki, see Category:Test pages.

This example page is outdated. The demo on this page is now just a small fraction of the fully functional script that this prototype helped to create. See w:c:dev:ListFiles for the completed script!

This is an example of using JavaScript with AJAX to query the allimages API and put the results in a sortable table. The URL (see JavaScript section below) being used is:

(localwiki) + /api.php?action=query&list=allimages&ailimit=1000&aiprop=size&format=json

  • &format=json is used in the URL to put the information into JavaScript Object Notation (JSON) format so that it can be used with JavaScript
  • To detect images of a minimum size of 1 MB, you would need to add &aiminsize=1000000 into the URL. In this example, I did not set the minimum file size because my test wiki here doesn't have any images larger than 1 MB.
  • The script is not currently set up to detect differences between file types. e.g. videos will pop up in the results.


Name Size (bytes) Width (px) Height (px)
This row is needed to "trick" sortable into working properly, but it's hidden so that it won't affect anything. Note: This table uses JavaScript to call the allimages API, so if you copy this table, you also need to copy the JavaScript that goes with it. -1 -1 -1


Screenshot of allimages page

JavaScript that goes with itEdit

$(function () {
	var $tbody = $('#allimages-sorting-table tbody');
	//********** URL FOR API CALL, YOU CAN CHANGE THIS **********
	var url = '/api.php?action=query&list=allimages&ailimit=1000&aiprop=size&format=json';
	// Callback function to execute with AJAX
	// Note: This function is highly dependent on the HTML structure of
	// the allimages-sorting-table. If you change the table, this function
	// will likely need to updated as well.
	function callback(data) {
		try {
			var newrows,
				allimages = data.query.allimages,
				len = allimages.length,
			for (i = 0; i < len; i++) {
				image = allimages[i];
				title = encodeURIComponent(image.title.replace(/ /g, '_'));
				newrows += '<tr><td><a href="/wiki/' + title + '">' + + '</a>'
						+ '</td><td>' + image.size
						+ '</td><td>' + image.width
						+ '</td><td>' + image.height
						+ '</td></tr>';
		} catch (e) {
			$tbody.append('<tr><td colspan=4>An error occured while querying allimages API. See your JavaScript console for more details.</td></tr>');
			console.log('An error occured while querying allimages API:', e);
	// query the API
	if ($tbody.length > 0) {
		$.getJSON(url, callback);

API informationEdit

See for information about the API

--- --- --- --- --- --- --- --- --- --- --- ---  Query: List  --- --- --- --- --- --- --- --- --- --- --- --- 

* list=allimages (ai) *
  Enumerate all images sequentially

This module requires read rights
  aifrom              - The image title to start enumerating from
  aito                - The image title to stop enumerating at
  aiprefix            - Search for all image titles that begin with this value
  aiminsize           - Limit to images with at least this many bytes
  aimaxsize           - Limit to images with at most this many bytes
  ailimit             - How many images in total to return
                        No more than 500 (5000 for bots) allowed
                        Default: 10
  aidir               - The direction in which to list
                        One value: ascending, descending
                        Default: ascending
  aisha1              - SHA1 hash of image. Overrides aisha1base36
  aisha1base36        - SHA1 hash of image in base 36 (used in MediaWiki)
  aiprop              - What image information to get:
                         timestamp     - Adds timestamp for the uploaded version
                         user          - Adds the user who uploaded the image version
                         userid        - Add the user ID that uploaded the image version
                         comment       - Comment on the version
                         parsedcomment - Parse the comment on the version
                         url           - Gives URL to the image and the description page
                         size          - Adds the size of the image in bytes and the height, width and page count (if applicable)
                         dimensions    - Alias for size
                         sha1          - Adds SHA-1 hash for the image
                         mime          - Adds MIME type of the image
                         thumbmime     - Adds MIME type of the image thumbnail (requires url)
                         mediatype     - Adds the media type of the image
                         metadata      - Lists EXIF metadata for the version of the image
                         bitdepth      - Adds the bit depth of the version
                        Values (separate with '|'): timestamp, user, userid, comment, parsedcomment, url, size, dimensions, sha1, mime, thumbmime,
                            mediatype, metadata, bitdepth
                        Default: timestamp|url
  aimime              - What MIME type to search for. e.g. image/jpeg. Disabled in Miser Mode
  Show a list of images starting at the letter "B":
  Show info about 4 images starting at the letter "T":
Help page:
  This module may be used as a generator