getUriForThumbnail() public method

public getUriForThumbnail ( Neos\Media\Domain\Model\ImageInterface $thumbnail ) : string
$thumbnail Neos\Media\Domain\Model\ImageInterface
return string
コード例 #1
0
 /**
  * Generate thumbnail and redirect to resource URI
  *
  * @param Thumbnail $thumbnail
  * @return void
  */
 public function thumbnailAction(Thumbnail $thumbnail)
 {
     if ($thumbnail->getResource() === null && $thumbnail->getStaticResource() === null) {
         $this->thumbnailService->refreshThumbnail($thumbnail);
     }
     $this->redirectToUri($this->thumbnailService->getUriForThumbnail($thumbnail), 0, 302);
 }
コード例 #2
0
 /**
  * Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
  * In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
  *
  * @param AssetInterface $asset
  * @param ThumbnailConfiguration $configuration
  * @param ActionRequest $request Request argument must be provided for asynchronous thumbnails
  * @return array|null Array with keys "width", "height" and "src" if the thumbnail generation work or null
  * @throws AssetServiceException
  */
 public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration, ActionRequest $request = null)
 {
     $thumbnailImage = $this->thumbnailService->getThumbnail($asset, $configuration);
     if (!$thumbnailImage instanceof ImageInterface) {
         return null;
     }
     $resource = $thumbnailImage->getResource();
     if ($thumbnailImage instanceof Thumbnail) {
         $staticResource = $thumbnailImage->getStaticResource();
         if ($configuration->isAsync() === true && $resource === null && $staticResource === null) {
             if ($request === null) {
                 throw new AssetServiceException('Request argument must be provided for async thumbnails.', 1447660835);
             }
             $this->uriBuilder->setRequest($request->getMainRequest());
             $uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('thumbnail', array('thumbnail' => $thumbnailImage), 'Thumbnail', 'Neos.Media');
         } else {
             $uri = $this->thumbnailService->getUriForThumbnail($thumbnailImage);
         }
     } else {
         $uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
     }
     return array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $uri);
 }
コード例 #3
0
 /**
  * @param Asset $asset
  * @return array
  */
 protected function getAssetProperties(Asset $asset)
 {
     $assetProperties = ['assetUuid' => $this->persistenceManager->getIdentifierByObject($asset), 'filename' => $asset->getResource()->getFilename()];
     $thumbnail = $this->thumbnailService->getThumbnail($asset, $this->thumbnailService->getThumbnailConfigurationForPreset('Neos.Media.Browser:Thumbnail'));
     if ($thumbnail !== null) {
         $assetProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail);
         $assetProperties['previewSize'] = ['w' => $thumbnail->getWidth(), 'h' => $thumbnail->getHeight()];
     }
     return $assetProperties;
 }