/** * @param Thumbnail $thumbnail * @return void * @throws Exception\NoThumbnailAvailableException */ public function refresh(Thumbnail $thumbnail) { try { $width = $thumbnail->getConfigurationValue('width') ?: $thumbnail->getConfigurationValue('maximumWidth'); $height = $thumbnail->getConfigurationValue('height') ?: $thumbnail->getConfigurationValue('maximumHeight'); /** @var AssetInterface $asset */ $asset = $thumbnail->getOriginalAsset(); $icon = FileTypeIconService::getIcon($asset, $width, $height); $thumbnail->setStaticResource($icon['src']); $thumbnail->setWidth($icon['width']); $thumbnail->setHeight($icon['height']); } catch (\Exception $exception) { $message = sprintf('Unable to generate thumbnail for the given image (filename: %s, SHA1: %s)', $thumbnail->getOriginalAsset()->getResource()->getFilename(), $thumbnail->getOriginalAsset()->getResource()->getSha1()); throw new Exception\NoThumbnailAvailableException($message, 1433109654, $exception); } }
/** * @param Thumbnail $thumbnail * @return void * @throws Exception\NoThumbnailAvailableException */ public function refresh(Thumbnail $thumbnail) { try { $width = $thumbnail->getConfigurationValue('width') ?: $thumbnail->getConfigurationValue('maximumWidth'); $height = $thumbnail->getConfigurationValue('height') ?: $thumbnail->getConfigurationValue('maximumHeight'); /** @var AssetInterface $asset */ $asset = $thumbnail->getOriginalAsset(); $thumbnail->setStaticResource($this->resourceManager->getPublicPersistentResourceUri($asset->getResource())); $thumbnail->setWidth($width); $thumbnail->setHeight($height); } catch (\Exception $exception) { $filename = $thumbnail->getOriginalAsset()->getResource()->getFilename(); $sha1 = $thumbnail->getOriginalAsset()->getResource()->getSha1(); $message = sprintf('Unable to generate thumbnail for the given SVG (filename: %s, SHA1: %s)', $filename, $sha1); throw new Exception\NoThumbnailAvailableException($message, 1433109654, $exception); } }