Extension:PageImages
|
PageImages Release status: experimental |
|||
|---|---|---|---|
| Implementation | API, Parser extension | ||
| Description | Stores information about images representing a page | ||
| Author(s) | Max Semenik (MaxSemtalk) | ||
| Last version | continuous updates | ||
| MediaWiki | 1.20+ | ||
| PHP | 5.3+ | ||
| Database changes | no | ||
| License | WTFPL 2.0 | ||
| Download | |||
|
|||
|
|||
| Check usage and version matrix; stats | |||
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.
Contents |
Downloading[edit]
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]
- Download and extract the files in a directory called "
PageImages" in your extensions/ folder. - Add the following code to your LocalSettings.php (at the bottom)
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]
Page images information is exposed via a new prop=pageimages API.
Parameters:
- piprop
- What information about the page images to return (can be one or more values, pipe-delimited):
- thumbnail - URL of image thumbnail.
- name - Image title.
- pithumbsize
- Width of thumbnail in pixels. If omitted a default of 50px will be used.
- pilimit
- Number of pages to proces.
- picontinue
- 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" }, } } }
/w/api.php?action=query&prop=pageimages&titles=Somepage&format=xml
<?xml version="1.0"?> <api> <query> <pages> <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" /> </page> </pages> </query> </api>
Configuration[edit]
$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 array( 'type' => 'db', 'page' => 'MediaWiki:Pageimages-blacklist', 'db' => false, ), // Page on Wikimedia Commons, for other Wikimedia projects array( 'type' => 'db', 'page' => 'MediaWiki:Pageimages-blacklist', 'db' => 'commonswiki', ), // Page on Commons, for third-party sites using our web API array( '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.
| This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |