Skip to content

Commit

Permalink
Rework the way image urls are rendered from relative to absolute links [
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-H committed Dec 15, 2019
1 parent 815c8ad commit 9933ddc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Helpers/RelativeImageRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ public function render(AbstractInline $inline, ElementRendererInterface $htmlRen
}

$url = $inline->getUrl();
if (strpos($this->relativeFilePath, '/index.md') !== false && strpos($url, '/') === false) {
$url = basename(dirname($this->relativeFilePath)) . '/' . $url;

$path = '/' . dirname($this->relativeFilePath) . '/';
$imageIsRelative = strpos($url, '/') !== 0 && strpos($url, 'http') !== 0;
if ($imageIsRelative) {
$url = $path . $url;
}

if (RegexHelper::isLinkPotentiallyUnsafe($url)) {
Expand Down

0 comments on commit 9933ddc

Please sign in to comment.