32 $this->repoGroup = $repoGroup;
33 $this->hookRunner =
new HookRunner( $hookContainer );
43 private function getFileNamesByPageId( array $identitiesByPageId ): array {
44 $fileIdentitiesByPageId = array_filter(
47 return $pageIdentity->getNamespace() ===
NS_FILE;
52 static function ( PageIdentity $pageIdentity ) {
53 return $pageIdentity->getDBkey();
55 $fileIdentitiesByPageId
67 $size ??= self::THUMBNAIL_SIZE;
69 $thumb = $file->
transform( [
'width' => $size ] );
70 if ( !$thumb || $thumb->isError() ) {
75 $thumb->getFile()->getMimeType(),
90 public function getThumbnails( array $pageIdentities, ?
int $size = 60 ): array {
92 $fileNamesByPageId = $this->getFileNamesByPageId( $pageIdentities );
94 foreach ( $fileNamesByPageId as $pageId => $fileName ) {
95 $file = $this->repoGroup->findFile( $fileName );
99 $thumbnail = $this->buildSearchResultThumbnailFromFile( $file, $size );
101 $results[$pageId] = $thumbnail;
106 $this->hookRunner->onSearchResultProvideThumbnail( $pageIdentities, $results, $size );
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL using $wgServer (or one of its alternatives).
Implements some public methods and some protected utility functions which are required by multiple ch...
getName()
Return the name of this file.
transform( $params, $flags=0)
Transform a media file.
Prioritized list of file repositories.
Interface for objects (potentially) representing an editable wiki page.