Neos\Media\ViewHelpers\ThumbnailViewHelper::render PHP Method

render() public method

Renders an HTML img tag with a thumbnail image, created from a given asset.
public render ( Neos\Media\Domain\Model\AssetInterface $asset = null, integer $width = null, integer $maximumWidth = null, integer $height = null, integer $maximumHeight = null, boolean $allowCropping = false, boolean $allowUpScaling = false, boolean $async = false, string $preset = null ) : string
$asset Neos\Media\Domain\Model\AssetInterface The asset to be rendered as a thumbnail
$width integer Desired width of the thumbnail
$maximumWidth integer Desired maximum width of the thumbnail
$height integer Desired height of the thumbnail
$maximumHeight integer Desired maximum height of the thumbnail
$allowCropping boolean Whether the thumbnail should be cropped if the given sizes would hurt the aspect ratio
$allowUpScaling boolean Whether the resulting thumbnail size might exceed the size of the original asset
$async boolean Return asynchronous image URI in case the requested image does not exist already
$preset string Preset used to determine image configuration
return string an 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();
    }