diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index d41c920b11..c1b6449865 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,13 +1,14 @@ -{{ $imagePath := .Destination }} -{{ if and (eq .Page.Kind "page") (not (hasPrefix .Destination "/")) }} - {{ $imagePath = (printf "../%s" .Destination) }} +{{- $u := urls.Parse .Destination -}} +{{- $src := $u.String -}} +{{ if not (or $u.IsAbs (strings.HasPrefix $u.String "/")) }} + {{ $base := urls.Parse .Page.Permalink }} + {{ $src = $base.JoinPath "../" $u.Path -}} {{ end }} -{{ $params := (urls.Parse $imagePath).Query }} -{{ $width := index $params "w" }} -{{ $height := index $params "h" }} -{{ $border := index $params "border" }} - +{{ $params := $u.Query }} +{{ $width := $params.Get "w" }} +{{ $height := $params.Get "h" }} +{{ $border := $params.Has "border" }}
{{ .Text }} {{ with .Title }} @@ -45,9 +41,8 @@ {{ .Text }}