### Install PageImages via Git Source: https://www.mediawiki.org/wiki/Extension:PageImages Commands to clone the PageImages extension repository into the extensions directory. ```bash cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages ``` -------------------------------- ### Format Denylist Wiki Page Source: https://www.mediawiki.org/wiki/Extension:PageImages Example content for the denylist wiki page. Ensure you include the colon before file links to prevent them from rendering as images. ```text * [[:File:First denylisted file.png]] * [[:File:Second denylisted file.jpeg]] ... ``` -------------------------------- ### Query PageImages for Albert Einstein Source: https://www.mediawiki.org/wiki/Extension:PageImages Example URL to retrieve the name and a 100-pixel thumbnail for the Albert Einstein page. ```text api.php?action=query&prop=pageimages&titles=Albert%20Einstein&pithumbsize=100 ``` -------------------------------- ### GET api.php?action=query&prop=pageimages Source: https://www.mediawiki.org/wiki/Extension:PageImages Returns information about images on a page, such as thumbnail and presence of photos. Use the piprop parameter to specify which information to return (thumbnail, name, original). ```APIDOC ## [GET] api.php?action=query&prop=pageimages ### Description Returns information about images on the page, such as thumbnail and presence of photos. This module requires read rights. ### Method GET ### Endpoint api.php?action=query&prop=pageimages ### Parameters #### Query Parameters - **action** (string) - Required - Must be `query`. - **prop** (string) - Required - Must be `pageimages`. - **titles** (string) - Required - Page titles to query (e.g., `Albert Einstein`). - **piprop** (string) - Optional - Which information to return. Values (separate with `|` or alternative): `name`, `original`, `thumbnail`. Default: `thumbnail|name`. - **pithumbsize** (integer) - Optional - Maximum width in pixels of thumbnail images. Default: 50. - **pilimit** (integer or `max`) - Optional - Properties of how many pages to return. Value must be between 1 and 50. Default: 50. - **pilicense** (string) - Optional - Limit page images to a certain license type. One of the following values: `any`, `free`. Default: `free`. - **picontinue** (integer) - Optional - When more results are available, use this to continue. - **pilangcode** (string) - Optional - Code for the language the image is going to be rendered in if multiple languages are supported. ### Request Example api.php?action=query&prop=pageimages&titles=Albert%20Einstein&pithumbsize=100 ### Response #### Success Response (200) - **pageimage** (string) - Source image filename (basename of original.source). Only present if piprop includes `name` and image exists. - **thumbnail** (object) - Thumbnail information. Only present if piprop includes `thumbnail` and image exists. - **source** (string) - Thumbnail image URL. - **width** (number) - Thumbnail image width in pixels. - **height** (number) - Thumbnail image height in pixels. - **original** (object) - Original image information. Only present if piprop includes `original` and image exists. - **source** (string) - Source image URL. - **width** (number) - Source image width in pixels. - **height** (number) - Source image height in pixels. #### Response Example { "query": { "normalized": [ { "from": "Lightbox_demo", "to": "Lightbox demo" } ], "pages": { "162510": { "pageid": 162510, "ns": 0, "title": "Lightbox demo", "thumbnail": { "source": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Crystal_Clear_app_korganizer.png/50px-Crystal_Clear_app_korganizer.png", "width": 50, "height": 50 }, "pageimage": "Crystal_Clear_app_korganizer.png" } } } } ``` -------------------------------- ### Exclude image via infobox parameter Source: https://www.mediawiki.org/wiki/Extension:PageImages Example of using the image_class parameter within an infobox template to exclude an image from being selected as the page image. ```wikitext {{Infobox type image=InappropriateImage.png image_class=notpageimage }} ``` -------------------------------- ### Configure $wgPageImagesDenylist Source: https://www.mediawiki.org/wiki/Extension:PageImages An array of sources for image denylists. Images listed here will never be selected as page images. ```php $wgPageImagesDenylist = [ // Page on local wiki [ 'type' => 'db', 'page' => 'MediaWiki:Pageimages-denylist', 'db' => false, ], // Page on Wikimedia Commons, for other Wikimedia projects using direct DB access [ 'type' => 'db', 'page' => 'MediaWiki:Pageimages-denylist', 'db' => 'commonswiki', ], // Page on Commons, for third-party sites using web access [ 'type' => 'url', 'url' => 'http://commons.wikimedia.org/w/index.php?title=somepage&action=raw', ], ]; ``` -------------------------------- ### Request Page Image for Lightbox_demo Source: https://www.mediawiki.org/wiki/Extension:PageImages A sample API request and its corresponding JSON response for the Lightbox_demo page. ```text api.php?action=query&prop=pageimages&titles=Lightbox_demo ``` ```json { "query": { "normalized": [ { "from": "Lightbox_demo", "to": "Lightbox demo" } ], "pages": { "162510": { "pageid": 162510, "ns": 0, "title": "Lightbox demo", "thumbnail": { "source": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Crystal_Clear_app_korganizer.png/50px-Crystal_Clear_app_korganizer.png", "width": 50, "height": 50 }, "pageimage": "Crystal_Clear_app_korganizer.png" } } } } ``` -------------------------------- ### Register PageImages in LocalSettings.php Source: https://www.mediawiki.org/wiki/Extension:PageImages Add this line to the bottom of your LocalSettings.php file to enable the extension. ```php wfLoadExtension( 'PageImages' ); ``` -------------------------------- ### Configure ratio scoring Source: https://www.mediawiki.org/wiki/Extension:PageImages The default configuration for image ratio scoring, where keys represent width divided by height (multiplied by 10) and values represent the scoring multiple. ```php $wgPageImagesScores['ratio'] = ["3" => -100, "5" => 0, "20" => 5, "30"=> 0, "31"=> -100]; ``` -------------------------------- ### PageImages API Response Structure Source: https://www.mediawiki.org/wiki/Extension:PageImages The expected JSON structure for the pageimages property, including optional thumbnail and original image details. ```json { // piprop.name (and image exists) pageimage?: string // Source image filename (basename of original.source). // piprop.thumbnail (and image exists) thumbnail?: { source: string // Thumbnail image URL. width: number // Thumbnail image width in pixels. height: number // Thumbnail image height in pixels. } // piprop.original (and image exists) original?: { source: string // Source image URL. width: number // Source image width in pixels. height: number // Source image height in pixels. } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.