From dd4cf5e8ac98f8a840cd4797f579c3310f2b79b8 Mon Sep 17 00:00:00 2001 From: Manuel Glauser Date: Sun, 14 May 2023 21:49:33 +0200 Subject: [PATCH] [BUGFIX] Strip superfluous srcset path prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rendering image '' elements using the IMAGE content object (layoutKey 'picture') no longer have the document root path prepended in the 'srcset' attribute. Resolves: #100867 Related: #95379 Releases: main, 12.4 Change-Id: Id49b0f9a41dd9760e25fc17386cae805f66083e9 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79030 Tested-by: core-ci Tested-by: Ben Robinson Reviewed-by: Benni Mack Tested-by: Benni Mack Tested-by: Stefan Bürk Reviewed-by: Stefan Bürk --- .../frontend/Classes/ContentObject/ImageContentObject.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php index 0b0aa2ead0bf..e456f3104384 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php @@ -214,14 +214,17 @@ protected function getImageSourceCollection($layoutKey, $conf, $file) $sourceConfiguration['height'] = $sourceInfo[1]; $urlPrefix = ''; + $publicUrl = str_starts_with($sourceInfo[3], Environment::getPublicPath()) + ? PathUtility::stripPathSitePrefix($sourceInfo[3]) + : $sourceInfo[3]; // Prepend 'absRefPrefix' to file path only if file was not processed // by FAL, e.g. GIFBUILDER - if (!isset($sourceInfo['originalFile']) && is_file(Environment::getPublicPath() . '/' . $sourceInfo['3'])) { + if (!isset($sourceInfo['originalFile']) && is_file(Environment::getPublicPath() . '/' . $publicUrl)) { $urlPrefix = $tsfe->absRefPrefix; } - $sourceConfiguration['src'] = htmlspecialchars($urlPrefix . $sourceInfo[3]); + $sourceConfiguration['src'] = htmlspecialchars($urlPrefix . $publicUrl); $sourceConfiguration['selfClosingTagSlash'] = $this->getPageRenderer()->getDocType()->isXmlCompliant() ? ' /' : ''; $oneSourceCollection = $this->markerTemplateService->substituteMarkerArray($sourceLayout, $sourceConfiguration, '###|###', true, true);