erynwells.me/layouts/photos/li_thumbnail_in_grid.html
Eryn Wells afb59e7862 Prepare thumbnails of all images in the photo post
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.
2023-04-06 08:45:35 -07:00

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>