Skip to content

Commit

Permalink
[BUGFIX] Let Image sources respect relative and absolute links config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
linawolf authored and jaapio committed Nov 21, 2023
1 parent f3caa80 commit 649c085
Show file tree
Hide file tree
Showing 19 changed files with 854 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/guides/src/Twig/AssetsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public function asset(array $context, string $path): string
{
$outputPath = $this->copyAsset($context['env'] ?? null, $path);

// make it relative so it plays nice with the base tag in the HEAD
return trim($outputPath, '/');
return $this->urlGenerator->generateInternalUrl($context['env'] ?? null, trim($outputPath, '/'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- content start -->
<div class="section" id="document-title">
<h1>Document Title</h1>

<p>Lorem Ipsum Dolor.</p>
<div class="section" id="a-local-image">
<h2>A local image</h2>

<img
src="/hero-illustration.svg"
width="400" alt="Alternative text" />

</div>

<div class="section" id="an-image-with-absolute-paths">
<h2>An image with absolute paths</h2>

<img
src="/images/hero2-illustration.svg"
width="400" alt="Alternative text" />

</div>

<div class="section" id="an-image-with-relative-paths">
<h2>An image with relative paths</h2>

<img
src="/images/hero2-illustration.svg"
width="400" alt="Alternative text" />

</div>

</div>

<!-- content end -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Subpage</title>

</head>
<body>
<!-- content start -->
<div class="section" id="subpage">
<h1>Subpage</h1>

<p>Lorem Ipsum Dolor.</p>
<div class="section" id="an-image-with-absolute-paths">
<h2>An image with absolute paths</h2>

<img
src="/images/hero2-illustration.svg"
width="400" alt="Alternative text" />

</div>

<div class="section" id="an-image-with-relative-paths">
<h2>An image with relative paths</h2>

<img
src="/subfolder/../images/hero2-illustration.svg"
width="400" alt="Alternative text" />

</div>

</div>

<!-- content end -->
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<guides xmlns="https://www.phpdoc.org/guides"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd"
links-are-relative="false"
>
</guides>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 649c085

Please sign in to comment.