From ffb85cddd0b25ad10fde369d14e597fca11570e1 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Fri, 11 Oct 2024 16:54:23 +0200 Subject: [PATCH] [FIX] use canonicalUrl to fetch images --- packages/guides/src/Twig/AssetsExtension.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/guides/src/Twig/AssetsExtension.php b/packages/guides/src/Twig/AssetsExtension.php index 16393d147..1bcb3fee3 100644 --- a/packages/guides/src/Twig/AssetsExtension.php +++ b/packages/guides/src/Twig/AssetsExtension.php @@ -156,25 +156,27 @@ private function copyAsset( } $canonicalUrl = $this->documentNameResolver->canonicalUrl($renderContext->getDirName(), $sourcePath); + $normalizedSourcePath = $this->documentNameResolver->canonicalUrl($renderContext->getDirName(), $sourcePath); + $outputPath = $this->documentNameResolver->absoluteUrl( $renderContext->getDestinationPath(), $canonicalUrl, ); try { - if ($renderContext->getOrigin()->has($sourcePath) === false) { + if ($renderContext->getOrigin()->has($normalizedSourcePath) === false) { $this->logger->error( - sprintf('Image reference not found "%s"', $sourcePath), + sprintf('Image reference not found "%s"', $normalizedSourcePath), $renderContext->getLoggerInformation(), ); return $outputPath; } - $fileContents = $renderContext->getOrigin()->read($sourcePath); + $fileContents = $renderContext->getOrigin()->read($normalizedSourcePath); if ($fileContents === false) { $this->logger->error( - sprintf('Could not read image file "%s"', $sourcePath), + sprintf('Could not read image file "%s"', $normalizedSourcePath), $renderContext->getLoggerInformation(), );