From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status stable

ImplementationTemplate:Extension#type API, Parser extension
DescriptionTemplate:Extension#description Stores information about images representing a page
Author(s)Template:Extension#username Max Semenik (MaxSemtalk)
Latest versionTemplate:Extension#version continuous updates
MediaWikiTemplate:Extension#mediawiki 1.20+
PHPTemplate:Extension#php 5.3+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license WTFPL 2.0
  • $wgPageImagesBlacklist
  • $wgPageImagesBlacklistExpiry
  • $wgPageImagesExpandOpenSearchXml
  • $wgPageImagesNamespaces
Hooks usedTemplate:Extension#hook

Translate the PageImages extension if it is available at translatewiki.net

Check usage and version matrix.


Open tasks ยท Report a bug

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.


  • Download and place the file(s) in a directory called PageImages in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/PageImages/PageImages.php";
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


The PageImages extension provides image information by adding a prop=pageimages to the Properties API for action=query.


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 process.
If more information is available, use this parameter to request it.

Sample request: Request page image for an article.


$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 the image detection in the opensearch API module with its own, more accurate results. Default: false.

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

The blacklist itself should contain a wikilinks to blacklisted files, the rest of content is irrelevant (and can contain links to other pages). For example:

* [[:File:First blacklisted file.png]]
* [[:File:Second blacklisted file.jpeg]]

Remember that file links that result in images being added to the page will not work (these files are blacklisted for a reason, right?), so don't forget the : in front of the links.

How it works[edit]

When a page is saved with a local image, the parser runs the hooks ParserMakeImageParams and LinksUpdate. The PageImages extension responds to these (and other hooks) and inserts a new property for the page into the page_props table. The property name is page_image and its value is the name of the image.

The extension only stores the chosen image name. Other features may display the image, such as Page information, Hovercards, and Mobile search while typing.

Image choice[edit]

The page image is chosen based on a number of criteria with limited documentation. It attempts to return only meaningful images, e.g. not those from maintenance templates, stubs or flag icons. Non-free images may be skipped for copyright reasons. Images with very different width and height may be skipped due to poor display in features using the image. The first image satisfying certain criteria may be chosen. No image will be chosen on some pages.

See also[edit]