Skip to content

Commit 68ba5d8

Browse files
committed
[FIX] use canonicalUrl to fetch images
(cherry picked from commit ffb85cd)
1 parent 304ec1c commit 68ba5d8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/guides/src/Twig/AssetsExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,25 +156,27 @@ private function copyAsset(
156156
}
157157

158158
$canonicalUrl = $this->documentNameResolver->canonicalUrl($renderContext->getDirName(), $sourcePath);
159+
$normalizedSourcePath = $this->documentNameResolver->canonicalUrl($renderContext->getDirName(), $sourcePath);
160+
159161
$outputPath = $this->documentNameResolver->absoluteUrl(
160162
$renderContext->getDestinationPath(),
161163
$canonicalUrl,
162164
);
163165

164166
try {
165-
if ($renderContext->getOrigin()->has($sourcePath) === false) {
167+
if ($renderContext->getOrigin()->has($normalizedSourcePath) === false) {
166168
$this->logger->error(
167-
sprintf('Image reference not found "%s"', $sourcePath),
169+
sprintf('Image reference not found "%s"', $normalizedSourcePath),
168170
$renderContext->getLoggerInformation(),
169171
);
170172

171173
return $outputPath;
172174
}
173175

174-
$fileContents = $renderContext->getOrigin()->read($sourcePath);
176+
$fileContents = $renderContext->getOrigin()->read($normalizedSourcePath);
175177
if ($fileContents === false) {
176178
$this->logger->error(
177-
sprintf('Could not read image file "%s"', $sourcePath),
179+
sprintf('Could not read image file "%s"', $normalizedSourcePath),
178180
$renderContext->getLoggerInformation(),
179181
);
180182

0 commit comments

Comments
 (0)