From 2b443bca8830fc43e72ac4e3b7aca368adbb2cd5 Mon Sep 17 00:00:00 2001 From: Luca Zeuch Date: Mon, 13 Jan 2025 12:23:16 +0100 Subject: [PATCH] images: avoid lightbox link collissions Some image IDs collide with eachother, because `.Ordinal` seems to be reset for no apparent reason. Hash the filename instead, thereby generating unique IDs (local to a single page) and avoiding their respective lightbox being in conflict. Signed-off-by: Luca Zeuch --- layouts/_default/_markup/render-image.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 4f5d8d7..846a405 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -92,13 +92,13 @@ {{- end }} {{- /* Determine id attribute. */}} -{{- $id := printf "h-rh-i-%d" .Ordinal }} +{{- $id := printf "h-rh-i-%s" (md5 $u.Path) }} {{- with .Attributes.id }} {{- $id = . }} {{- end }} {{- /* Initialize attributes. */}} -{{- $attrs := merge .Attributes (dict "id" $id "alt" .Text "title" (.Title | transform.HTMLEscape) "src" $u.String) }} +{{- $attrs := merge .Attributes (dict "id" $id "alt" .Text "title" (.Title | transform.HTMLEscape) "src" $u.Path) }} {{- /* Merge attributes from resource. */}} {{- with $r }}