39 return $isFree ? self::PROP_NAME_FREE : self::PROP_NAME;
55 $fileName =
$dbr->selectField(
'page_props',
58 'pp_page' =>
$title->getArticleID(),
59 'pp_propname' => [ self::PROP_NAME, self::PROP_NAME_FREE ]
62 [
'ORDER BY' =>
'pp_propname' ]
84 $imageFile = self::getPageImage(
$context->getTitle() );
90 $thumbSetting =
$context->getUser()->getOption(
'thumbsize' );
93 $thumb = $imageFile->transform( [
'width' => $thumbSize ] );
97 $imageHtml = $thumb->toHtml(
99 'alt' => $imageFile->getTitle()->getText(),
104 $pageInfo[
'header-basic'][] = [
105 $context->msg(
'pageimages-info-label' ),
116 global $wgPageImagesExpandOpenSearchXml;
118 if ( !$wgPageImagesExpandOpenSearchXml || !count( $results ) ) {
122 $pageIds = array_keys( $results );
123 $data = self::getImages( $pageIds, 50 );
124 foreach ( $pageIds as $id ) {
125 if ( isset( $data[$id][
'thumbnail'] ) ) {
126 $results[$id][
'image'] = $data[$id][
'thumbnail'];
128 $results[$id][
'image'] =
null;
144 foreach ( $watchlist as $ns => $pages ) {
145 foreach ( array_keys( $pages ) as $dbKey ) {
146 $title = Title::makeTitle( $ns, $dbKey );
149 $id =
$title->getArticleID();
156 $data = self::getImages( array_keys( $ids ) );
157 foreach ( $data as $id => $page ) {
158 if ( isset( $page[
'pageimage'] ) ) {
159 $images[ $page[
'ns'] ][ $ids[$id] ] = $page[
'pageimage'];
172 private static function getImages( array $pageIds, $size = 0 ) {
174 foreach ( array_chunk( $pageIds, ApiBase::LIMIT_SML1 ) as $chunk ) {
177 'prop' =>
'pageimages',
179 'pageids' => implode(
'|', $chunk ),
184 $request[
'piprop'] =
'thumbnail';
185 $request[
'pithumbsize'] = $size;
191 $ret += (array)$api->getResult()->getResultData(
192 [
'query',
'pages' ], [
'Strip' =>
'base' ]
203 $imageFile = self::getPageImage( $out->
getContext()->getTitle() );
209 $thumb = $imageFile->transform( [
'width' => 1200 ] );
$wgThumbLimits
Adjust thumbnails on image pages according to a user setting.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfFindFile( $title, $options=[])
Find a file.
This is the main API class, used for both external and internal processing.
getContext()
Get the base IContextSource object.
WebRequest clone which takes values from a provided array.
This is one of the Core classes and should be read at least once by any new developers.
addMeta( $name, $val)
Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:".
static getPageImage(Title $title)
Returns page image for a given title.
static onSpecialMobileEditWatchlistImages(IContextSource $context, array $watchlist, array &$images)
SpecialMobileEditWatchlist::images hook handler, adds images to mobile watchlist A-Z view.
static onApiOpenSearchSuggest(array &$results)
ApiOpenSearchSuggest hook handler, enhances ApiOpenSearch results with this extension's data.
static getImages(array $pageIds, $size=0)
Returns image information for pages with given ids.
static onInfoAction(IContextSource $context, &$pageInfo)
InfoAction hook handler, adds the page image to the info=action page.
const PROP_NAME_FREE
Page property used to store the best free page image information Note changing this value is not advi...
const PROP_NAME
Page property used to store the best page image information.
static onBeforePageDisplay(OutputPage &$out, Skin &$skin)
static getPropName( $isFree)
Get property name used in page_props table.
The main skin class which provides methods and properties for all other skins.
Represents a title within MediaWiki.
Interface for objects which can provide a MediaWiki context on request.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.