@@ -21,65 +21,65 @@ |
||
| 21 | 21 | class ThumbnailViewHelper extends AbstractViewHelper |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function initializeArguments() |
|
| 28 | - { |
|
| 29 | - $this->registerArgument('file', 'mixed', 'The source file', false, null); |
|
| 30 | - $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []); |
|
| 31 | - $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, ''); |
|
| 32 | - $this->registerArgument('preset', 'string', 'Image dimension preset', false, ''); |
|
| 33 | - $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image'); |
|
| 34 | - $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, ''); |
|
| 35 | - } |
|
| 24 | + /** |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function initializeArguments() |
|
| 28 | + { |
|
| 29 | + $this->registerArgument('file', 'mixed', 'The source file', false, null); |
|
| 30 | + $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []); |
|
| 31 | + $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, ''); |
|
| 32 | + $this->registerArgument('preset', 'string', 'Image dimension preset', false, ''); |
|
| 33 | + $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image'); |
|
| 34 | + $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, ''); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Returns a configurable thumbnail of an asset |
|
| 39 | - * |
|
| 40 | - * @throws \Exception |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - public function render() |
|
| 44 | - { |
|
| 37 | + /** |
|
| 38 | + * Returns a configurable thumbnail of an asset |
|
| 39 | + * |
|
| 40 | + * @throws \Exception |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + public function render() |
|
| 44 | + { |
|
| 45 | 45 | |
| 46 | - $file = $this->arguments['file']; |
|
| 47 | - $preset = $this->arguments['preset']; |
|
| 48 | - $configuration = $this->arguments['configuration']; |
|
| 49 | - if (!is_array($configuration)) { |
|
| 50 | - $configuration = array(); |
|
| 51 | - } |
|
| 52 | - $configurationWrap = $this->arguments['configurationWrap']; |
|
| 53 | - $attributes = $this->arguments['attributes']; |
|
| 54 | - $output = $this->arguments['output']; |
|
| 46 | + $file = $this->arguments['file']; |
|
| 47 | + $preset = $this->arguments['preset']; |
|
| 48 | + $configuration = $this->arguments['configuration']; |
|
| 49 | + if (!is_array($configuration)) { |
|
| 50 | + $configuration = array(); |
|
| 51 | + } |
|
| 52 | + $configurationWrap = $this->arguments['configurationWrap']; |
|
| 53 | + $attributes = $this->arguments['attributes']; |
|
| 54 | + $output = $this->arguments['output']; |
|
| 55 | 55 | |
| 56 | - if ($file instanceof Content) { |
|
| 57 | - $file = $this->getFileConverter()->convert($file); |
|
| 58 | - } elseif (!($file instanceof File)) { |
|
| 59 | - $file = ResourceFactory::getInstance()->getFileObject((int)$file); |
|
| 60 | - } |
|
| 61 | - if ($preset) { |
|
| 62 | - $imageDimension = ImagePresetUtility::getInstance()->preset($preset); |
|
| 63 | - $configuration['width'] = $imageDimension->getWidth(); |
|
| 64 | - $configuration['height'] = $imageDimension->getHeight(); |
|
| 65 | - } |
|
| 66 | - /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */ |
|
| 67 | - $thumbnailService = GeneralUtility::makeInstance('Fab\Media\Thumbnail\ThumbnailService', $file); |
|
| 68 | - $thumbnail = $thumbnailService->setConfiguration($configuration) |
|
| 69 | - ->setConfigurationWrap($configurationWrap) |
|
| 70 | - ->setAttributes($attributes) |
|
| 71 | - ->setOutputType($output) |
|
| 72 | - ->create(); |
|
| 56 | + if ($file instanceof Content) { |
|
| 57 | + $file = $this->getFileConverter()->convert($file); |
|
| 58 | + } elseif (!($file instanceof File)) { |
|
| 59 | + $file = ResourceFactory::getInstance()->getFileObject((int)$file); |
|
| 60 | + } |
|
| 61 | + if ($preset) { |
|
| 62 | + $imageDimension = ImagePresetUtility::getInstance()->preset($preset); |
|
| 63 | + $configuration['width'] = $imageDimension->getWidth(); |
|
| 64 | + $configuration['height'] = $imageDimension->getHeight(); |
|
| 65 | + } |
|
| 66 | + /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */ |
|
| 67 | + $thumbnailService = GeneralUtility::makeInstance('Fab\Media\Thumbnail\ThumbnailService', $file); |
|
| 68 | + $thumbnail = $thumbnailService->setConfiguration($configuration) |
|
| 69 | + ->setConfigurationWrap($configurationWrap) |
|
| 70 | + ->setAttributes($attributes) |
|
| 71 | + ->setOutputType($output) |
|
| 72 | + ->create(); |
|
| 73 | 73 | |
| 74 | - return $thumbnail; |
|
| 75 | - } |
|
| 74 | + return $thumbnail; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @return \Fab\Media\TypeConverter\ContentToFileConverter |
|
| 79 | - */ |
|
| 80 | - protected function getFileConverter() |
|
| 81 | - { |
|
| 82 | - return GeneralUtility::makeInstance('Fab\Media\TypeConverter\ContentToFileConverter'); |
|
| 83 | - } |
|
| 77 | + /** |
|
| 78 | + * @return \Fab\Media\TypeConverter\ContentToFileConverter |
|
| 79 | + */ |
|
| 80 | + protected function getFileConverter() |
|
| 81 | + { |
|
| 82 | + return GeneralUtility::makeInstance('Fab\Media\TypeConverter\ContentToFileConverter'); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |