findMediaDisplayInfo() public method

Finds all the information needed to generate an url to the media and to display the media. The method finds the information for all medias with given ids.
public findMediaDisplayInfo ( $ids, $locale ) : array
$ids array The ids of the medias for which the info should be found
$locale string The locale in which the display info should be loaded
return array
Beispiel #1
0
 /**
  * Return assets by id for given attributes.
  *
  * @param array $attributesByTag
  * @param string $locale
  *
  * @return array
  */
 private function preloadMedias($attributesByTag, $locale)
 {
     $ids = array_unique(array_values(array_map(function ($attributes) {
         return $attributes['id'];
     }, $attributesByTag)));
     $medias = $this->mediaRepository->findMediaDisplayInfo($ids, $locale);
     $result = [];
     foreach ($medias as $media) {
         $media['url'] = $this->mediaManager->getUrl($media['id'], $media['name'], $media['version']);
         $result[$media['id']] = $media;
     }
     return $result;
 }