Adds thumbnails and image urls.
public addFormatsAndUrl ( |
||
$media | ||
return |
/** * {@inheritdoc} */ public function findByFilters($filters, $page, $pageSize, $limit, $locale, $options = []) { if (!array_key_exists('dataSource', $filters) || $filters['dataSource'] === '' || $limit !== null && $limit < 1) { return []; } if ($filters['dataSource'] === 'root') { // if root collection is selected remove filter for data-source $filters['dataSource'] = null; } $entities = $this->parentFindByFilters($filters, $page, $pageSize, $limit, $locale, $options); return array_map(function (Media $media) use($locale) { return $this->mediaManager->addFormatsAndUrl(new MediaApi($media, $locale)); }, $entities); }
private function resolveMediaObject($media, $locale) { if ($media instanceof MediaEntity) { return $this->mediaManager->addFormatsAndUrl(new MediaApi($media, $locale)); } elseif ($media instanceof MediaApi) { return $this->mediaManager->addFormatsAndUrl($media); } return; }
/** * Return the image URL for the given media. * * TODO: The media API needs to be improved here. */ private function getImageUrl($media, $locale) { $mediaApi = new Media($media, $locale); $this->mediaManager->addFormatsAndUrl($mediaApi); $formats = $mediaApi->getThumbnails(); if (!isset($formats[$this->searchImageFormat])) { $this->logger->warning(sprintf('Media with ID "%s" does not have thumbnail format "%s". This thumbnail would be used by the search results.', $media->getId(), $this->searchImageFormat)); return; } return $formats[$this->searchImageFormat]; }