/** * Renders the path to a thumbnail image, created from a given asset. * * @param ImageInterface $image * @param integer $maximumWidth Desired maximum height of the image * @param integer $maximumHeight Desired maximum width of the image * @param boolean $allowCropping Whether the image should be cropped if the given sizes would hurt the aspect ratio * @param boolean $allowUpScaling Whether the resulting image size might exceed the size of the original image * @return string the relative image path, to be used as src attribute for <img /> tags */ public function render(ImageInterface $image = NULL, $maximumWidth = NULL, $maximumHeight = NULL, $allowCropping = FALSE, $allowUpScaling = FALSE) { if ($image === NULL && $this->hasArgument('asset')) { $image = $this->arguments['asset']; } return $this->assetService->getThumbnailUriAndSizeForAsset($image, $maximumWidth, $maximumHeight, $allowCropping, $allowUpScaling)['src']; }
/** * Renders the path to a thumbnail image, created from a given asset. * * @param ImageInterface $image * @param integer $width Desired width of the image * @param integer $maximumWidth Desired maximum width of the image * @param integer $height Desired height of the image * @param integer $maximumHeight Desired maximum height of the image * @param boolean $allowCropping Whether the image should be cropped if the given sizes would hurt the aspect ratio * @param boolean $allowUpScaling Whether the resulting image size might exceed the size of the original image * @return string the relative image path, to be used as src attribute for <img /> tags */ public function render(ImageInterface $image = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false) { if ($image === null && $this->hasArgument('asset')) { $image = $this->arguments['asset']; } $thumbnailConfiguration = new ThumbnailConfiguration($width, $maximumWidth, $height, $maximumHeight, $allowCropping, $allowUpScaling); return $this->assetService->getThumbnailUriAndSizeForAsset($image, $thumbnailConfiguration)['src']; }
/** * 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']; }
/** * 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()); return $this->assetService->getThumbnailUriAndSizeForAsset($asset, $thumbnailConfiguration)['src']; }
/** * Renders an HTML img tag with a thumbnail image, created from a given asset. * * @param ImageInterface $image The image to be rendered as an image * @param integer $maximumWidth Desired maximum height of the image * @param integer $maximumHeight Desired maximum width of the image * @param boolean $allowCropping Whether the image should be cropped if the given sizes would hurt the aspect ratio * @param boolean $allowUpScaling Whether the resulting image size might exceed the size of the original image * * @return string an <img...> html tag */ public function render(ImageInterface $image = NULL, $maximumWidth = NULL, $maximumHeight = NULL, $allowCropping = FALSE, $allowUpScaling = FALSE) { if ($image === NULL && $this->hasArgument('asset')) { $image = $this->arguments['asset']; } $thumbnailData = $this->assetService->getThumbnailUriAndSizeForAsset($image, $maximumWidth, $maximumHeight, $allowCropping, $allowUpScaling); $this->tag->addAttributes(array('width' => $thumbnailData['width'], 'height' => $thumbnailData['height'], 'src' => $thumbnailData['src'])); return $this->tag->render(); }
/** * Renders an HTML img tag with a thumbnail image, created from a given asset. * * @param ImageInterface $image The image to be rendered as an image * @param integer $width Desired width of the image * @param integer $maximumWidth Desired maximum width of the image * @param integer $height Desired height of the image * @param integer $maximumHeight Desired maximum height of the image * @param boolean $allowCropping Whether the image should be cropped if the given sizes would hurt the aspect ratio * @param boolean $allowUpScaling Whether the resulting image size might exceed the size of the original image * @return string an <img...> html tag */ public function render(ImageInterface $image = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false) { if ($image === null && $this->hasArgument('asset')) { $image = $this->arguments['asset']; } $thumbnailConfiguration = new ThumbnailConfiguration($width, $maximumWidth, $height, $maximumHeight, $allowCropping, $allowUpScaling); $thumbnailData = $this->assetService->getThumbnailUriAndSizeForAsset($image, $thumbnailConfiguration); $this->tag->addAttributes(array('width' => $thumbnailData['width'], 'height' => $thumbnailData['height'], 'src' => $thumbnailData['src'])); return $this->tag->render(); }
/** * Returns a processed image path * * @return string */ public function evaluate() { $asset = $this->getAsset(); $maximumWidth = $this->getMaximumWidth(); $maximumHeight = $this->getMaximumHeight(); $allowCropping = $this->getAllowCropping(); $allowUpScaling = $this->getAllowUpScaling(); if (!$asset instanceof AssetInterface) { throw new \Exception('No asset given for rendering.', 1415184217); } return $this->assetService->getThumbnailUriAndSizeForAsset($asset, $maximumWidth, $maximumHeight, $allowCropping, $allowUpScaling)['src']; }
public function render(\TYPO3\Media\Domain\Model\ImageInterface $image = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false) { if ($this->hasArgument('theme') && $this->hasArgument('imageVariant')) { $themeSettings = $this->getSettingsForCurrentTheme($this->arguments['theme']); $imageVariantSettings = $themeSettings['imageVariants'][$this->arguments['imageVariant']]; $width = $imageVariantSettings['width']; $maximumWidth = $imageVariantSettings['maximumWidth']; $height = $imageVariantSettings['height']; $maximumHeight = $imageVariantSettings['maximumHeight']; $allowCropping = $imageVariantSettings['allowCropping']; $allowUpScaling = $imageVariantSettings['allowUpScaling']; } $thumbnailConfiguration = new ThumbnailConfiguration($width, $maximumWidth, $height, $maximumHeight, $allowCropping, $allowUpScaling); $imageData = $this->assetService->getThumbnailUriAndSizeForAsset($image, $thumbnailConfiguration); $imageData['title'] = $image->getTitle(); $imageData['caption'] = $image->getCaption(); if ($this->hasArgument('key')) { return $imageData[$this->arguments['key']]; } else { return $imageData; } }
/** * @param NodeInterface $article * @return array */ protected function buildSingleItemJson(NodeInterface $article) { $contentCollection = $article->getChildNodes('TYPO3.Neos:ContentCollection')[0]; $articleBody = ''; if ($contentCollection instanceof NodeInterface) { $content = $contentCollection->getChildNodes(); if (is_array($content) && array_key_exists(0, $content)) { foreach ($content as $node) { /** @var NodeInterface $node */ if ($node->getNodeType()->getName() === 'TYPO3.Neos.NodeTypes:Text' || $node->getNodeType()->getName() === 'TYPO3.Neos.NodeTypes:TextWithImage') { $articleBody .= $node->getProperty('text'); } } } } $thumbnailConfiguration = new ThumbnailConfiguration(125, 125, 125, 125, true, true, false); $detailConfiguration = new ThumbnailConfiguration(300, 300, 200, 200, true, true, false); /** @var Image $image */ $image = $article->getProperty('headerImage'); $properties = ['@context' => 'http://schema.org', '@type' => 'Article', '@id' => $article->getIdentifier(), 'id' => $article->getIdentifier(), 'shortIdentifier' => explode('-', $article->getIdentifier())[0], 'title' => $article->getProperty('title'), 'articleBody' => $articleBody, 'publicationDate' => $article->getProperty('publicationDate')->format('D M d Y H:i:s O'), 'teaser' => $article->getProperty('article'), 'listImage' => $this->assetService->getThumbnailUriAndSizeForAsset($image, $thumbnailConfiguration)['src'], 'image' => $this->assetService->getThumbnailUriAndSizeForAsset($image, $detailConfiguration)['src']]; $this->processProperties($properties); return $properties; }
/** * 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(); }
/** * @param array $items array of Resources,Assets or strings (uri) * @param string $id of the carousel instance * @param string $class class attribute of carousel element * @param bool $autoinclude include scripts and styles if not already done * @param int $numItems number of items to display at once * @param bool $itemsScaleUp scale up carousel items * @param bool $singleItem always display a single item * @param bool $showNavigation show carousel navigation * @param bool $pagination enable pagination * @param int $paginationSpeed speed of the pagination * @param bool $paginationNumbers show pagination numbers * @param bool $rewindNavigation rewind navigation on end * @param bool $autoplay enable autoplay * @param int $autoplaySpeed speed of autoplay * @param bool $pauseOnHover pause autoplay on hover * @param bool $loop loop animation instead of rewind * @param bool $isResponsive enable responsive design * @param array<string,int> $responsiveConfig responsive configuration array("{minScreenSize}" => [numElements],...)) * @param int $itemMaxWidth image thumbnail max width * @param int $itemMaxHeight image thumbnail max height * @param bool $itemAllowCropping allow cropping thumbnails * @param bool $itemAllowUpscaling allow upscaling thumbnails * * @return string */ public function render($items, $id = null, $class = null, $autoinclude = true, $numItems = 1, $itemsScaleUp = true, $singleItem = true, $showNavigation = true, $pagination = true, $paginationSpeed = 800, $paginationNumbers = true, $rewindNavigation = true, $autoplay = true, $autoplaySpeed = 200, $pauseOnHover = true, $loop = true, $isResponsive = false, $responsiveConfig = array("0" => 1, "479" => 2, "768" => 3, "1199" => 5), $itemMaxWidth = null, $itemMaxHeight = null, $itemAllowCropping = false, $itemAllowUpscaling = false) { if ($id == null) { $id = 'oc' . md5(microtime()); } if ($class == null) { $class = 'owl-carousel'; } else { $class .= ' owl-carousel'; } //build config array $config = array(); $config['items'] = $numItems; $config['itemsScaleUp'] = $itemsScaleUp; $config['singleItem'] = $singleItem; $config['nav'] = $showNavigation; $config['pagination'] = $pagination; $config['paginationSpeed'] = $paginationSpeed; $config['paginationNumbers'] = $paginationNumbers; $config['rewindNav'] = $rewindNavigation; $config['autoplay'] = $autoplay; $config['autoplaySpeed'] = $autoplaySpeed; $config['autoplayHoverPause'] = $pauseOnHover; $config['loop'] = $loop; $config['responsiveClass'] = $isResponsive; //include dependencies if necessary $includeContent = ''; if ($autoinclude) { $viewHelper = $this->objectManager->get('Axovis\\Flow\\Owlcarousel\\ViewHelpers\\IncludeViewHelper'); $includeContent = $viewHelper->render(true, 'remaining'); } //build items content $itemsContent = ''; foreach ($items as $item) { $title = ''; $caption = ''; if ($item instanceof Resource) { $uri = $this->resourceManager->getPublicPersistentResourceUri($item); } else { if ($item instanceof Asset) { $thumbnailConfiguration = new ThumbnailConfiguration(null, $itemMaxWidth, null, $itemMaxHeight, $itemAllowCropping, $itemAllowUpscaling, false); $uri = $this->assetService->getThumbnailUriAndSizeForAsset($item, $thumbnailConfiguration)['src']; //$uri = $this->resourceManager->getPublicPersistentResourceUri($item->getResource()); $title = $item->getTitle(); $caption = $item->getCaption(); } else { if (is_string($item)) { $uri = $item; } else { $title = 'Dummy Image'; $uri = $this->resourceManager->getPublicPackageResourceUri('Axovis.Flow.Owlcarousel', 'Images/dummy-image.png'); } } } $itemsContent .= ' <div class="item"> <div> <img src="' . $uri . '" title="' . $title . '" alt="' . $title . '" /> <div class="carousel-caption"> ' . $caption . ' </div> </div> </div> '; } //build responsive config content $responsiveConfigContent = ''; if ($isResponsive) { $responsiveConfigContent = 'config.responsive = {};'; foreach ($responsiveConfig as $screen => $numItems) { $responsiveConfigContent .= ' config.responsive["' . $screen . '"] = {}; config.responsive["' . $screen . '"].items = ' . $numItems . '; '; } } return ' ' . $includeContent . ' <div id="' . $id . '" class="' . $class . '"> ' . $itemsContent . ' </div> <script type="text/javascript"> $(document).ready(function(){ var config = ' . json_encode($config, JSON_NUMERIC_CHECK) . '; ' . $responsiveConfigContent . ' $("#' . $id . '").owlCarousel(config); }); </script> '; }