Allow thumbnails to be provided in a different size

This will also be added to the interface, but first this
implementation needs to be updated to already accept the
optional new param. Doing it in different order would
cause incompatible declaration warnings.

Bug: T306883
Change-Id: Ia30afcc43a0ecec772cd0a82dd9661e61f31a651
This commit is contained in:
Matthias Mullie 2022-08-23 14:03:45 +02:00 committed by Matthias Mullie
parent 3ab47c1061
commit a8c8030299

View file

@ -113,13 +113,14 @@ class SearchResultProvideThumbnailHookHandler implements SearchResultProvideThum
/** /**
* @param array $pageIdentities array that contain $pageId => SearchResultPageIdentity. * @param array $pageIdentities array that contain $pageId => SearchResultPageIdentity.
* @param array &$results Placeholder for result. $pageId => SearchResultThumbnail * @param array &$results Placeholder for result. $pageId => SearchResultThumbnail
* @param int|null $size size of thumbnail height and width in points
*/ */
public function onSearchResultProvideThumbnail( array $pageIdentities, &$results ): void { public function onSearchResultProvideThumbnail( array $pageIdentities, &$results, int $size = null ): void {
$pageIdTitles = array_map( static function ( PageIdentity $identity ) { $pageIdTitles = array_map( static function ( PageIdentity $identity ) {
return Title::makeTitle( $identity->getNamespace(), $identity->getDBkey() ); return Title::makeTitle( $identity->getNamespace(), $identity->getDBkey() );
}, $pageIdentities ); }, $pageIdentities );
$data = $this->getThumbnails( $pageIdTitles, self::THUMBNAIL_SIZE ); $data = $this->getThumbnails( $pageIdTitles, $size ?? self::THUMBNAIL_SIZE );
foreach ( $data as $pageId => $thumbnail ) { foreach ( $data as $pageId => $thumbnail ) {
$results[ $pageId ] = $thumbnail; $results[ $pageId ] = $thumbnail;
} }