From 2a5f81c04e6e050d15f4ebe984182469f951a664 Mon Sep 17 00:00:00 2001 From: Manuel Glauser <mail@manuelglauser.ch> 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 '<source>' 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/+/79682 Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> --- .../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 5179b08b8364..567f25e610a6 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php @@ -214,14 +214,17 @@ class ImageContentObject extends AbstractContentObject $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); -- GitLab