/**
  * Renders the path to a thumbnail image, created from a given asset.
  *
  * @param AssetInterface $asset
  * @param integer $width Desired width of the thumbnail
  * @param integer $maximumWidth Desired maximum width of the thumbnail
  * @param integer $height Desired height of the thumbnail
  * @param integer $maximumHeight Desired maximum height of the thumbnail
  * @param boolean $allowCropping Whether the thumbnail should be cropped if the given sizes would hurt the aspect ratio
  * @param boolean $allowUpScaling Whether the resulting thumbnail size might exceed the size of the original asset
  * @param boolean $async Return asynchronous image URI in case the requested image does not exist already
  * @param string $preset Preset used to determine image configuration
  * @return string the relative thumbnail path, to be used as src attribute for <img /> tags
  */
 public function render(AssetInterface $asset = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false, $async = false, $preset = null)
 {
     if ($preset) {
         $thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset, $async);
     } else {
         $thumbnailConfiguration = new ThumbnailConfiguration($width, $maximumWidth, $height, $maximumHeight, $allowCropping, $allowUpScaling, $async);
     }
     return $this->assetService->getThumbnailUriAndSizeForAsset($asset, $thumbnailConfiguration, $this->controllerContext->getRequest())['src'];
 }
 /**
  * Fetches possible usages of the asset and registers nodes that use the asset as changed.
  *
  * @param AssetInterface $asset
  * @return void
  */
 public function registerAssetResourceChange(AssetInterface $asset)
 {
     if (!$asset->isInUse()) {
         return;
     }
     foreach ($this->assetService->getUsageReferences($asset) as $reference) {
         if (!$reference instanceof AssetUsageInNodeProperties) {
             continue;
         }
         $this->registerNodeChange($reference->getNode());
     }
 }
 /**
  * Replace the resource on an asset.
  *
  * @param AssetInterface $asset
  * @param PersistentResource $resource
  * @param array $options
  * @return void
  */
 public function updateAssetResourceAction(AssetInterface $asset, PersistentResource $resource, array $options = [])
 {
     try {
         $originalFilename = $asset->getLabel();
         $this->assetService->replaceAssetResource($asset, $resource, $options);
     } catch (\Exception $exception) {
         $this->addFlashMessage('couldNotReplaceAsset', '', Message::SEVERITY_OK, [], 1463472606);
         $this->forwardToReferringRequest();
     }
     $this->addFlashMessage('assetHasBeenReplaced', '', Message::SEVERITY_OK, [htmlspecialchars($originalFilename)]);
     $this->redirect('index');
 }
 /**
  * Returns a processed image path
  *
  * @return string
  * @throws \Exception
  */
 public function evaluate()
 {
     $asset = $this->getAsset();
     if (!$asset instanceof AssetInterface) {
         throw new \Exception('No asset given for rendering.', 1415184217);
     }
     $thumbnailConfiguration = new ThumbnailConfiguration($this->getWidth(), $this->getMaximumWidth(), $this->getHeight(), $this->getMaximumHeight(), $this->getAllowCropping(), $this->getAllowUpScaling());
     $thumbnailData = $this->assetService->getThumbnailUriAndSizeForAsset($asset, $thumbnailConfiguration);
     if ($thumbnailData === null) {
         return '';
     }
     return $thumbnailData['src'];
 }
 /**
  * Renders an HTML img tag with a thumbnail image, created from a given asset.
  *
  * @param AssetInterface $asset The asset to be rendered as a thumbnail
  * @param integer $width Desired width of the thumbnail
  * @param integer $maximumWidth Desired maximum width of the thumbnail
  * @param integer $height Desired height of the thumbnail
  * @param integer $maximumHeight Desired maximum height of the thumbnail
  * @param boolean $allowCropping Whether the thumbnail should be cropped if the given sizes would hurt the aspect ratio
  * @param boolean $allowUpScaling Whether the resulting thumbnail size might exceed the size of the original asset
  * @param boolean $async Return asynchronous image URI in case the requested image does not exist already
  * @param string $preset Preset used to determine image configuration
  * @return string an <img...> html tag
  */
 public function render(AssetInterface $asset = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false, $async = false, $preset = null)
 {
     if ($preset) {
         $thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset, $async);
     } else {
         $thumbnailConfiguration = new ThumbnailConfiguration($width, $maximumWidth, $height, $maximumHeight, $allowCropping, $allowUpScaling, $async);
     }
     $thumbnailData = $this->assetService->getThumbnailUriAndSizeForAsset($asset, $thumbnailConfiguration, $this->controllerContext->getRequest());
     if ($thumbnailData === null) {
         return '';
     }
     $this->tag->addAttributes(array('width' => $thumbnailData['width'], 'height' => $thumbnailData['height'], 'src' => $thumbnailData['src']));
     return $this->tag->render();
 }
 /**
  * Returns the number of times the asset is in use.
  *
  * @return integer
  * @api
  */
 public function getUsageCount()
 {
     return $this->assetService->getUsageCount($this);
 }
 /**
  * @param AssetInterface $object
  */
 public function update($object)
 {
     parent::update($object);
     $this->assetService->emitAssetUpdated($object);
 }