Skip to content

Commit 3f96cb6

Browse files
fix(layouts): override render-image hook for Hugo 0.154 compatibility
Stack theme requires Hugo 0.157+ (reflect.IsImageResourceWithMeta), which breaks all external image rendering on 0.154. Add project-level render-image override that handles external URLs with plain <img> tags. Co-Authored-By: Paperclip <noreply@paperclip.ing>
1 parent 0e0a955 commit 3f96cb6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

layouts/_markup/render-image.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- $url := urls.Parse .Destination -}}
2+
{{- $alt := .PlainText | safeHTML -}}
3+
{{- $isExternal := in (slice "https" "http") $url.Scheme -}}
4+
5+
{{- if $isExternal -}}
6+
<img src="{{ .Destination }}" alt="{{ $alt }}" loading="lazy">
7+
{{- else -}}
8+
{{- $image := .Page.Resources.Get .Destination -}}
9+
{{- if $image -}}
10+
<img src="{{ $image.RelPermalink }}" alt="{{ $alt }}" width="{{ $image.Width }}" height="{{ $image.Height }}" loading="lazy">
11+
{{- else -}}
12+
<img src="{{ .Destination }}" alt="{{ $alt }}" loading="lazy">
13+
{{- end -}}
14+
{{- end -}}

0 commit comments

Comments
 (0)