From a8c803029972bfb6e8bfbd9ce5bbfe98f5e118b7 Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Tue, 23 Aug 2022 14:03:45 +0200 Subject: [PATCH] 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 --- includes/Hooks/SearchResultProvideThumbnailHookHandler.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/Hooks/SearchResultProvideThumbnailHookHandler.php b/includes/Hooks/SearchResultProvideThumbnailHookHandler.php index e26ba35..02875c1 100644 --- a/includes/Hooks/SearchResultProvideThumbnailHookHandler.php +++ b/includes/Hooks/SearchResultProvideThumbnailHookHandler.php @@ -113,13 +113,14 @@ class SearchResultProvideThumbnailHookHandler implements SearchResultProvideThum /** * @param array $pageIdentities array that contain $pageId => SearchResultPageIdentity. * @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 ) { return Title::makeTitle( $identity->getNamespace(), $identity->getDBkey() ); }, $pageIdentities ); - $data = $this->getThumbnails( $pageIdTitles, self::THUMBNAIL_SIZE ); + $data = $this->getThumbnails( $pageIdTitles, $size ?? self::THUMBNAIL_SIZE ); foreach ( $data as $pageId => $thumbnail ) { $results[ $pageId ] = $thumbnail; }