diff options
| author | Reorx <novoreorx@gmail.com> | 2022-05-20 18:19:35 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-05-20 18:19:35 +0800 |
| commit | 228cf0d83f6972d57c735dac273635a7f022aeac (patch) | |
| tree | e7a8e3d73643f30438258db66daaad29ea8c43f4 /layouts | |
| parent | 3f1e99e8b484e9e778dd3dc65302b3623f1b3c83 (diff) | |
use RelPermalink for markdown images
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/_markup/render-image.html | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 1acb87d..9c3c9a7 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1 +1,9 @@ -<img loading="lazy" src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} /> +{{- $img := .Page.Resources.GetMatch .Destination -}} +{{- if and (not $img) .Page.File -}} + {{ $path := path.Join .Page.File.Dir .Destination }} + {{- $img = resources.Get $path -}} +{{- end -}} + +{{- with $img -}} + <img loading="lazy" src="{{ $img.RelPermalink }}" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} /> +{{- end -}} |
