Skip to content

Commit

Permalink
[FIX] use canonicalUrl to fetch images
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapio authored and linawolf committed Oct 11, 2024
1 parent 0adfe93 commit ffb85cd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/guides/src/Twig/AssetsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);

Expand Down

0 comments on commit ffb85cd

Please sign in to comment.