public render ( Neos\Media\Domain\Model\ImageInterface $image = 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 | ||
$image | Neos\Media\Domain\Model\ImageInterface | The image to be rendered as an image |
$width | integer | Desired width of the image |
$maximumWidth | integer | Desired maximum width of the image |
$height | integer | Desired height of the image |
$maximumHeight | integer | Desired maximum height of the image |
$allowCropping | boolean | Whether the image should be cropped if the given sizes would hurt the aspect ratio |
$allowUpScaling | boolean | Whether the resulting image size might exceed the size of the original image |
$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 |
public function render(ImageInterface $image = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false, $async = false, $preset = null)
{
if ($image === null && $this->hasArgument('asset')) {
$image = $this->arguments['asset'];
}
if ($image === null) {
return '';
}
if ($preset) {
$thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset, $async);
} else {
$thumbnailConfiguration = new ThumbnailConfiguration($width, $maximumWidth, $height, $maximumHeight, $allowCropping, $allowUpScaling, $async);
}
$thumbnailData = $this->assetService->getThumbnailUriAndSizeForAsset($image, $thumbnailConfiguration, $this->controllerContext->getRequest());
if ($thumbnailData === null) {
return '';
}
$this->tag->addAttribute('src', $thumbnailData['src']);
if ($thumbnailData['width'] > 0 && $thumbnailData['height'] > 0) {
$this->tag->addAttributes(array('width' => $thumbnailData['width'], 'height' => $thumbnailData['height']));
}
return $this->tag->render();
}