Skip to content

Commit 42a9f98

Browse files
committed
BUGFIX: Prevent render error if asset is not set in ImageTag
As the thumbnail is generated within „context“ conditions don’t apply yet which could prevent the rendering and therefore the error.
1 parent c2f3ec5 commit 42a9f98

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Neos.Media/Classes/Eel/ImageHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ImageHelper implements ProtectedContextAwareInterface
4141
* @throws ThumbnailServiceException
4242
*/
4343
public function createThumbnail(
44-
AssetInterface $asset,
44+
?AssetInterface $asset,
4545
string $preset = null,
4646
int $width = null,
4747
int $maximumWidth = null,
@@ -53,6 +53,9 @@ public function createThumbnail(
5353
int $quality = null,
5454
string $format = null
5555
): ?ImageInterface {
56+
if (!$asset instanceof AssetInterface) {
57+
return null;
58+
}
5659
if (!empty($preset)) {
5760
$thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset);
5861
} else {

Neos.Neos/Resources/Private/Fusion/Prototypes/ImageTag.fusion

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ prototype(Neos.Neos:ImageTag) < prototype(Neos.Fusion:Tag) {
1010
async = false
1111
quality = NULL
1212
preset = NULL
13-
@context.thumbnail = ${Neos.Media.Image.createThumbnail(
13+
@context.thumbnail = ${this.asset ? Neos.Media.Image.createThumbnail(
1414
this.asset,
1515
this.preset,
1616
this.width,
@@ -22,7 +22,7 @@ prototype(Neos.Neos:ImageTag) < prototype(Neos.Fusion:Tag) {
2222
this.async,
2323
this.quality,
2424
this.format
25-
)}
25+
) : null}
2626

2727
tagName = 'img'
2828
attributes {

0 commit comments

Comments
 (0)