Skip to content

Commit

Permalink
[BUGFIX] Strip superfluous srcset path prefix
Browse files Browse the repository at this point in the history
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/+/79030
Tested-by: core-ci <typo3@b13.com>
Tested-by: Ben Robinson <robinson2.ben@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
ManuelGlauser authored and sbuerk committed Jul 4, 2023
1 parent bb72ee0 commit dd4cf5e
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -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);
Expand Down

0 comments on commit dd4cf5e

Please sign in to comment.