From 9a5a1edc970f072a7fa692f1f39913502a111c53 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Sat, 14 Mar 2026 10:35:48 +0100 Subject: [PATCH] Enhance ImageViewHelper to support additional attributes If argument loading is provided, always load it and also add all others in 14 --- Classes/ViewHelpers/ImageViewHelper.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Classes/ViewHelpers/ImageViewHelper.php b/Classes/ViewHelpers/ImageViewHelper.php index 405fad5..6230139 100644 --- a/Classes/ViewHelpers/ImageViewHelper.php +++ b/Classes/ViewHelpers/ImageViewHelper.php @@ -290,6 +290,10 @@ protected function buildSingleTag(string $tagName, array $configuration, FileInt if ($this->pictureConfiguration->lazyLoadingShouldBeAdded()) { $tag->addAttribute('loading', $this->pictureConfiguration->getLazyLoading()); } + // override if set + if (isset($this->additionalArguments['loading'])) { + $tag->addAttribute('loading', $this->additionalArguments['loading']); + } if ((new Typo3Version())->getMajorVersion() < 14) { $alt = $this->arguments['alt'] ?? $image->getProperty('alternative'); @@ -297,6 +301,9 @@ protected function buildSingleTag(string $tagName, array $configuration, FileInt } else { $alt = (string)($this->additionalArguments['alt'] ?? $image->getProperty('alternative')); $title = $this->additionalArguments['title'] ?? $image->getProperty('title'); + + unset($this->additionalArguments['alt'], $this->additionalArguments['title']); + $tag->addAttributes($this->additionalArguments); } // The alt-attribute is mandatory to have valid html-code, therefore add it even if it is empty