Add <img> tags for all thumbnails to the photos list entry. I'm hoping with lazy loading and some JavaScript this will not be terrible! Break the logic for preparing a thumbnail into a separate helper partial template so it can be reused.
11 lines
675 B
HTML
11 lines
675 B
HTML
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" 600 "Height" 600) -}}
|
|
{{- $thumbnail = $thumbnail.Crop "600x600" -}}
|
|
{{- $numberOfImages := len (partial "photos/list.html" .) -}}
|
|
{{- $hasMultipleImages := gt $numberOfImages 1 -}}
|
|
<a href="{{ .RelPermalink }}" title="{{ .Title }}" data-number-of-images="{{ $numberOfImages }}">
|
|
{{ if $hasMultipleImages }}<div class="badge">{{ $numberOfImages }}</div>{{ end }}
|
|
{{ range partial "photos/thumbnails.html" (dict "Page" . "Height" 600 "Width" 600) -}}
|
|
{{- $altText := .Params.alt -}}
|
|
<img src="{{ .RelPermalink }}"{{ with $altText }} alt="{{ . }}"{{ end }} loading="lazy">
|
|
{{- end }}
|
|
</a>
|