MediaWiki  1.34.0
PageImages Class Reference

Static Public Member Functions

static getPageImage (Title $title)
 Returns page image for a given title. More...
 
static getPropName ( $isFree)
 Get property name used in page_props table. More...
 
static onApiOpenSearchSuggest (array &$results)
 ApiOpenSearchSuggest hook handler, enhances ApiOpenSearch results with this extension's data. More...
 
static onBeforePageDisplay (OutputPage &$out, Skin &$skin)
 
static onInfoAction (IContextSource $context, &$pageInfo)
 InfoAction hook handler, adds the page image to the info=action page. More...
 
static onSpecialMobileEditWatchlistImages (IContextSource $context, array $watchlist, array &$images)
 SpecialMobileEditWatchlist::images hook handler, adds images to mobile watchlist A-Z view. More...
 

Public Attributes

const PROP_NAME = 'page_image'
 Page property used to store the best page image information. More...
 
const PROP_NAME_FREE = 'page_image_free'
 Page property used to store the best free page image information Note changing this value is not advised as it will invalidate all existing page property names on a production instance and cause them to be regenerated. More...
 

Static Private Member Functions

static getImages (array $pageIds, $size=0)
 Returns image information for pages with given ids. More...
 

Detailed Description

Note
WTFPL
Author
Max Semenik
Brad Jorsch
Thiemo Kreuz

Definition at line 9 of file PageImages.php.

Member Function Documentation

◆ getImages()

static PageImages::getImages ( array  $pageIds,
  $size = 0 
)
staticprivate

Returns image information for pages with given ids.

Parameters
int[]$pageIds
int$size
Returns
array[]

Definition at line 172 of file PageImages.php.

References ApiBase\LIMIT_SML1.

Referenced by onApiOpenSearchSuggest(), and onSpecialMobileEditWatchlistImages().

◆ getPageImage()

static PageImages::getPageImage ( Title  $title)
static

Returns page image for a given title.

Parameters
Title$titleTitle to get page image for
Returns
File|bool

Definition at line 49 of file PageImages.php.

References $dbr, $file, $title, DB_REPLICA, NS_FILE, PROP_NAME, PROP_NAME_FREE, wfFindFile(), and wfGetDB().

Referenced by onBeforePageDisplay(), onInfoAction(), and PageImages\Tests\PageImagesTest\testGivenNonExistingPageGetPageImageReturnsFalse().

◆ getPropName()

static PageImages::getPropName (   $isFree)
static

Get property name used in page_props table.

When a page image is stored it will be stored under this property name on the corresponding article.

Parameters
bool$isFreeWhether the image is a free-license image
Returns
string

Definition at line 38 of file PageImages.php.

References PROP_NAME, and PROP_NAME_FREE.

Referenced by PageImages\Hooks\LinksUpdateHookHandler\doLinksUpdate(), ApiQueryPageImages\execute(), ApiQueryPageImages\getPropNames(), PageImages\Tests\ApiQueryPageImagesTest\testExecute(), and PageImages\Tests\PageImagesTest\testGetPropName().

◆ onApiOpenSearchSuggest()

static PageImages::onApiOpenSearchSuggest ( array &  $results)
static

ApiOpenSearchSuggest hook handler, enhances ApiOpenSearch results with this extension's data.

Parameters
array[]&$resultsArray of results to add page images too

Definition at line 115 of file PageImages.php.

References getImages().

◆ onBeforePageDisplay()

static PageImages::onBeforePageDisplay ( OutputPage &  $out,
Skin $skin 
)
static
Parameters
OutputPage&$outThe page being output.
Skin&$skinSkin object used to generate the page. Ignored

Definition at line 202 of file PageImages.php.

References getPageImage(), PROTO_CANONICAL, and wfExpandUrl().

Referenced by PageImages\Tests\PageImagesTest\testGivenNonExistingPageOnBeforePageDisplayDoesNotAddMeta().

◆ onInfoAction()

static PageImages::onInfoAction ( IContextSource  $context,
$pageInfo 
)
static

InfoAction hook handler, adds the page image to the info=action page.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/InfoAction
Parameters
IContextSource$contextContext, used to extract the title of the page
array[]&$pageInfoAuxillary information about the page.

Definition at line 81 of file PageImages.php.

References $context, $wgThumbLimits, and getPageImage().

◆ onSpecialMobileEditWatchlistImages()

static PageImages::onSpecialMobileEditWatchlistImages ( IContextSource  $context,
array  $watchlist,
array &  $images 
)
static

SpecialMobileEditWatchlist::images hook handler, adds images to mobile watchlist A-Z view.

Parameters
IContextSource$contextContext object. Ignored
array[]$watchlistArray of relevant pages on the watchlist, sorted by namespace
array[]&$imagesArray of images to populate

Definition at line 140 of file PageImages.php.

References $title, getImages(), and Title\makeTitle().

Member Data Documentation

◆ PROP_NAME

const PageImages::PROP_NAME = 'page_image'

Page property used to store the best page image information.

If the best image is the same as the best image with free license, then nothing is stored under this property. Note changing this value is not advised as it will invalidate all existing page property names on a production instance and cause them to be regenerated.

See also
PageImages::PROP_NAME_FREE

Definition at line 20 of file PageImages.php.

Referenced by getPageImage(), getPropName(), PageImages\Tests\ApiQueryPageImagesTest\provideExecute(), PageImages\Tests\ApiQueryPageImagesTest\provideGetPropName(), PageImages\Tests\Hooks\LinksUpdateHookHandlerTest\testDoLinksUpdate(), and PageImages\Tests\PageImagesTest\testPagePropertyNames().

◆ PROP_NAME_FREE

const PageImages::PROP_NAME_FREE = 'page_image_free'

Page property used to store the best free page image information Note changing this value is not advised as it will invalidate all existing page property names on a production instance and cause them to be regenerated.

Definition at line 28 of file PageImages.php.

Referenced by getPageImage(), getPropName(), PageImages\Tests\ApiQueryPageImagesTest\provideExecute(), PageImages\Tests\ApiQueryPageImagesTest\provideGetPropName(), PageImages\Tests\Hooks\LinksUpdateHookHandlerTest\testDoLinksUpdate(), and PageImages\Tests\PageImagesTest\testPagePropertyNames().


The documentation for this class was generated from the following file: