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

Release status: beta

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 it is available at translatewiki.net

Check usage and version matrix; code metrics


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, 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.

Installation[edit | edit source]

  • 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.

API[edit | edit source]

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 imformation is available, use this parameter to request it.

Sample request: Request page image for an article.

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 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.

How it works[edit | edit source]

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.

See also[edit | edit source]