Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Let Image sources respect relative and absolute links config… #695

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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