From e6beb9332c4a40b19b3bd7dbaefba502b8fbdbd3 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 23 Jul 2020 13:06:12 +0200 Subject: [PATCH] BUGFIX: Allow ImageInterface to be returned in UploadedImageViewHelper The way the property mapping works, instead of Image an ImageVariant can be returned. To make this non-breaking, the return type of `getUploadedImage()` is relaxed. --- Classes/ViewHelpers/Form/UploadedImageViewHelper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Classes/ViewHelpers/Form/UploadedImageViewHelper.php b/Classes/ViewHelpers/Form/UploadedImageViewHelper.php index e7deb1c..39f32ee 100644 --- a/Classes/ViewHelpers/Form/UploadedImageViewHelper.php +++ b/Classes/ViewHelpers/Form/UploadedImageViewHelper.php @@ -15,6 +15,7 @@ use Neos\Flow\Property\PropertyMapper; use Neos\FluidAdaptor\ViewHelpers\Form\AbstractFormFieldViewHelper; use Neos\Media\Domain\Model\Image; +use Neos\Media\Domain\Model\ImageInterface; /** * This ViewHelper makes the specified Image object available for its @@ -73,17 +74,17 @@ public function render(): string * Returns a previously uploaded image. * If errors occurred during property mapping for this property, NULL is returned * - * @return Image + * @return ImageInterface * @throws \Neos\Flow\Property\Exception * @throws \Neos\Flow\Security\Exception */ - protected function getUploadedImage(): ?Image + protected function getUploadedImage(): ?ImageInterface { if ($this->getMappingResultsForProperty()->hasErrors()) { return null; } $image = $this->getPropertyValue(); - if ($image instanceof Image) { + if ($image instanceof ImageInterface) { return $image; } return $this->propertyMapper->convert($this->getValueAttribute(), Image::class);