Skip to content

Commit

Permalink
images: avoid lightbox link collissions
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
l-zeuch committed Jan 13, 2025
1 parent 2017ab4 commit 2b443bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 2b443bc

Please sign in to comment.