From 9f8e0de63dbb1ccd8ac7c99dfcaa0989f23710d4 Mon Sep 17 00:00:00 2001 From: Sp-cy <68587155+Sp-cy@users.noreply.github.com> Date: Mon, 17 Jun 2024 07:28:51 -0600 Subject: [PATCH] Update render-image.html to fix dimbox in List View (#636) * Updated the render-image render hook based on the official HUGO embedded render image hook so it works in the List View when noSummary is enabled in the post's front matter. --- v4/layouts/_default/_markup/render-image.html | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/v4/layouts/_default/_markup/render-image.html b/v4/layouts/_default/_markup/render-image.html index 1ffc1db64..cd980b5f5 100644 --- a/v4/layouts/_default/_markup/render-image.html +++ b/v4/layouts/_default/_markup/render-image.html @@ -1,12 +1,42 @@ +{{- $u := urls.Parse .Destination -}} +{{- $src := $u.String -}} +{{- if not $u.IsAbs -}} + {{- $path := strings.TrimPrefix "./" $u.Path }} + {{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}} + {{- $src = .RelPermalink -}} + {{- with $u.RawQuery -}} + {{- $src = printf "%s?%s" $src . -}} + {{- end -}} + {{- with $u.Fragment -}} + {{- $src = printf "%s#%s" $src . -}} + {{- end -}} + {{- end -}} +{{- end -}} +{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" (.Title | transform.HTMLEscape)) -}} + +{{- /* Define the href for the anchor tag, it could be same as the image src or another variable */ -}} +{{- $href := $src | default $src -}} + {{ if .Title }}
- - {{ .Text }} + +
{{ .Title }}
{{ else }} - - {{ .Text }} + + {{ end }} +{{- /**/ -}}