From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png

Release status: experimental

Implementation API, Parser extension
Description Stores information about images representing a page
Author(s) Max Semenik (MaxSemtalk)
Latest version continuous updates
MediaWiki 1.20+
PHP 5.3+
Database changes no
License WTFPL 2.0
  • $wgPageImagesBlacklist
  • $wgPageImagesBlacklistExpiry
  • $wgPageImagesExpandOpenSearchXml
  • $wgPageImagesNamespaces
Hooks used


Translate the PageImages extension if possible

Check usage and version matrix; code metrics
Bugs: list open list all report

The PageImages extension collects information about images used on a page.

Its aim is to return the single most appropriate thumbnail associated with an article, attempting to return only meaningful images, e.g. not those from maintenance templates, stubs or flag icons. Currently it uses the first non-meaningless image used in the page.

Downloading[edit | edit source]

You can download the extension directly from the MediaWiki source code repository (browse code). You can get:

One of the extensions tags

Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag

  • Go to the tags list
  • Click the name of the tag you want to download
  • Click "snapshot"
The latest version of one of the extensions branches

Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.

  • Go to the branches list
  • Click the branch name
  • Click "snapshot"
A snapshot made during the release of a MediaWiki version.

This might be unstable and is not guaranteed to work with the associated MediaWiki version.

After you've got the code, save it into the extensions/PageImages directory of your wiki.

If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:

cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/PageImages.git

Installation[edit | edit source]

  • Download and extract the files in a directory called PageImages in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.
  • Add the following code at the bottom of your LocalSettings.php:
require_once( "$IP/extensions/PageImages/PageImages.php" );
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

API[edit | edit source]

Page images information is exposed via a new prop=pageimages API.


What information about the page images to return (can be one or more values, pipe-delimited):
  • thumbnail - URL of image thumbnail.
  • name - Image title.
Width of thumbnail in pixels. If omitted a default of 50px will be used.
Number of pages to proces.
If more imformation is available, use this parameter to request it.

Example: /w/api.php?action=query&prop=pageimages&titles=Somepage&format=json

	"query": {
		"pages": {
			"1": {
				"pageid": 123,
				"ns": 0,
				"title": "Somepage",
				"thumbnail": {
					"source": "http:\/\/example.com\/w\/images\/thumb\/7\/70\/Example.png\/48px-Example.png",
					"width": 48,
					"height": 50
				"pageimage": "Example.png"


<?xml version="1.0"?>
      <page pageid="123" ns="0" title="Somepage" pageimage="Example.png">
        <thumbnail source="http://example.com/w/images/thumb/7/70/Example.png/48px-Example.png" width="48" height="50" />

Configuration[edit | edit source]

$wgPageImagesBlacklist is an array of sources for image blacklists. Blacklisted images will never be selected as page images. Examples:

$wgPageImagesBlacklist = array(
	// Page on local wiki
		'type' => 'db',
		'page' => 'MediaWiki:Pageimages-blacklist',
		'db' => false,
	// Page on Wikimedia Commons, for other Wikimedia projects
		'type' => 'db',
		'page' => 'MediaWiki:Pageimages-blacklist',
		'db' => 'commonswiki',
	// Page on Commons, for third-party sites using our web API
		'type' => 'url',
		'url' => 'http://commons.wikimedia.org/w/index.php?title=somepage&action=raw',

More than one source can be used at the same time.

$wgPageImagesBlacklistExpiry determines how long the blacklist will remain cached, in seconds. Default: 15 * 60 (15 minutes).

$wgPageImagesExpandOpenSearchXml if set to true, PageImages will override Extension:OpenSearchXml's image detection with its own, more accurate results. Default: false.

$wgPageImagesNamespaces is an array of namespaces PageImages will be activated on. Default: NS_MAIN.