{{- /* One image in a gallery, see gallery.html. Params: src the image, a file in the page's folder (page resource) or in assets/ alt what the image shows (required); also shown in the lightbox credit photographer, licence; shown under the thumbnail and in the lightbox */ -}} {{- if ne .Parent.Name "gallery" -}} {{- errorf "gallery-image: use it inside {{< gallery >}}: %s" .Position -}} {{- end -}} {{- $src := .Get "src" -}} {{- $alt := .Get "alt" -}} {{- $credit := .Get "credit" -}} {{- if not $alt -}} {{- errorf "gallery-image: %q needs an alt text: %s" $src .Position -}} {{- end -}} {{- $image := or (.Page.Resources.Get (strings.TrimPrefix "./" $src)) (resources.Get $src) -}} {{- if not $image -}} {{- errorf "gallery-image: no image %q in the page's folder or in assets/: %s" $src .Position -}} {{- else if or (ne $image.ResourceType "image") (eq $image.MediaType.SubType "svg") -}} {{- errorf "gallery-image: %q is not a photo Hugo can resize: %s" $src .Position -}} {{- else -}} {{- /* Square thumbnails at two sizes, never larger than the image itself. */ -}} {{- $side := math.Min 800 $image.Width $image.Height | int -}} {{- $small := $image.Fill (printf "%dx%d Smart" (div $side 2) (div $side 2)) -}} {{- $large := $image.Fill (printf "%dx%d Smart" $side $side) -}}