Skip to content

Commit 2b443bc

Browse files
committed
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 <[email protected]>
1 parent 2017ab4 commit 2b443bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

layouts/_default/_markup/render-image.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@
9292
{{- end }}
9393

9494
{{- /* Determine id attribute. */}}
95-
{{- $id := printf "h-rh-i-%d" .Ordinal }}
95+
{{- $id := printf "h-rh-i-%s" (md5 $u.Path) }}
9696
{{- with .Attributes.id }}
9797
{{- $id = . }}
9898
{{- end }}
9999

100100
{{- /* Initialize attributes. */}}
101-
{{- $attrs := merge .Attributes (dict "id" $id "alt" .Text "title" (.Title | transform.HTMLEscape) "src" $u.String) }}
101+
{{- $attrs := merge .Attributes (dict "id" $id "alt" .Text "title" (.Title | transform.HTMLEscape) "src" $u.Path) }}
102102

103103
{{- /* Merge attributes from resource. */}}
104104
{{- with $r }}

0 commit comments

Comments
 (0)