{{ $sourcePath := .sourcePath | default "images" }} {{ $gallery := site.GetPage $sourcePath }} {{ $imageDataUrl := "" }} {{ $s := slice }} {{ $params := site.Params.gallerydeluxe }} {{ with $gallery.Resources.ByType "image" }} {{ range . }} {{ $thumbs := partial "gallerydeluxe/create-thumbs.html" . }} {{ $20 := (index $thumbs "20") }} {{ $colors := slice }} {{ $exif := dict }} {{ if $params.enable_exif }} {{/* Workaround for https://github.com/gohugoio/hugo/issues/10345 */}} {{ $tags := newScratch }} {{ range $k, $v := .Exif.Tags }} {{ $tags.Set $k $v }} {{ end }} {{ $exif = dict "Tags" $tags.Values "Date" .Exif.Date "Lat" .Exif.Lat "Long" .Exif.Long }} {{ end }} {{ if (ge hugo.Version "0.104") }} {{/* .Colors method was added in Hugo 0.104.0 */}} {{ $colors = $20.Colors }} {{ end }} {{ $m := dict "name" .Name "full" .RelPermalink "exif" $exif "width" .Width "height" .Height "colors" $colors "20" $20.RelPermalink "100" (index $thumbs "100").RelPermalink "250" (index $thumbs "250").RelPermalink "500" (index $thumbs "500").RelPermalink }} {{ $s = $s | append $m }} {{ end }} {{ $r := $s | jsonify | resources.FromString (printf "%s-gallery.json" $sourcePath) }} {{ if hugo.IsProduction }} {{ $r = $r | minify | fingerprint }} {{ end }} {{ $imageDataUrl = $r.RelPermalink }} {{ else }} {{ errorf "gallerydeluxe: No bundle found in %q. sourcePath must be set to a valid Hugo bundle with JPG images in it." $sourcePath }} {{ end }} {{ return (dict "imageDataUrl" $imageDataUrl ) }}