From d250d1f65794f497b67ad6282a9155ebeafb59dc Mon Sep 17 00:00:00 2001 From: Oliver Bartsch <bo@cedev.de> Date: Tue, 2 Jan 2024 14:52:22 +0100 Subject: [PATCH] [BUGFIX] Fetch original file from file reference in ThumbnailViewHelper Using `treatIdAsReference` it's also possible to pass a file reference uid to the ThumbnailViewHelper. To allow processing such reference, the original file is now fetched to call `process` on it. Resolves: #102571 Releases: main, 12.4 Change-Id: If2f9cad99045d19c6dcc4b95bba6b7de71405956 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82375 Reviewed-by: Oliver Bartsch <bo@cedev.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> --- Build/phpstan/phpstan-baseline.neon | 5 ----- .../backend/Classes/ViewHelpers/ThumbnailViewHelper.php | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index e172d852e17c..f713a4189bf9 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -200,11 +200,6 @@ parameters: count: 1 path: ../../typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php - - - message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface\\:\\:process\\(\\)\\.$#" - count: 1 - path: ../../typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php - - message: "#^Parameter \\#2 \\$attributeValue of method TYPO3Fluid\\\\Fluid\\\\Core\\\\ViewHelper\\\\TagBuilder\\:\\:addAttribute\\(\\) expects array\\|string\\|Traversable\\|null, TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\ImageManipulation\\\\Area given\\.$#" count: 1 diff --git a/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php index eccab3130b05..6bbd47f2995f 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php @@ -133,6 +133,11 @@ final class ThumbnailViewHelper extends AbstractTagBasedViewHelper } } + if (is_callable([$image, 'getOriginalFile'])) { + // Get the original file from the file reference + $image = $image->getOriginalFile(); + } + $processedFile = $image->process($this->arguments['context'], $processingInstructions); $imageUri = $processedFile->getPublicUrl(); -- GitLab