+ {{ range $original := sort $images "Name" $sortOrder}}
+ {{ if eq $original.ResourceType "image" }}
+
+ {{/* Get metadata from sidecar file, if present. Else an empty dictionary is used. */}}
+ {{ $metaFileName := print $original.Name ".meta"}}
+
+ {{ $metadata := slice }}
+ {{ if and $globalMatch (not $localMatch) }}
+ {{ $metadata = resources.GetMatch ($metaFileName) }}
+ {{ else }}
+ {{ $metadata = $currentPage.Page.Resources.GetMatch ($metaFileName) }}
+ {{ end }}
+
+ {{ if $metadata }}
+ {{ $metadata = $metadata.Content }}
+ {{ $metadata = $metadata | unmarshal }}
+ {{ else }}
+ {{ $metadata = dict }}
+ {{ end }}
+
+ {{/* If the image has EXIF informations, those are merged together with the metadata from the file */}}
+ {{ if in "jpeg png tiff webp" $original.MediaType.SubType }}
+ {{ with $original.Exif }}
+ {{ $metadata = merge .Tags $metadata }}
+ {{ end }}
+ {{ end }}
+
+
+ {{/* Correct orientation of the image, this is needed for thumbnails (and downscaled gallery images)
+ if the EXIF informations contains an orientation value. See issue #22. */}}
+ {{ $rotated := $original.Filter images.AutoOrient }}
+
+
+ {{ $full := "" }}
+ {{ if $imageResizeOptions }}
+ {{/* Downscale gallery image, rotate it if needed */}}
+ {{ $full = ($rotated.Fit $imageResizeOptions) }}
+ {{ else }}
+ {{/* No need to use the rotated here, the browser will handle care of EXIF orientation */}}
+ {{ $full = $original }}
+ {{ end }}
+
+ {{ $thumbnail := "" }}
+ {{ if eq $thumbnailResizeOptions "original" }}
+ {{/* If thumbnailResizeOptions is set to 'original', use the original (unmodified) image for the thumbnail */}}
+ {{ $thumbnail = $original }}
+ {{ else if eq $thumbnailResizeOptions "full" }}
+ {{/* If thumbnailResizeOptions is set to 'full', use the same image as the lightbox for the thumbnail */}}
+ {{ $thumbnail = $full }}
+ {{ else }}
+ {{/* Create thumbnail, rotate it if needed */}}
+ {{ $thumbnail = ($rotated.Fit $thumbnailResizeOptions) }}
+ {{ end }}
+
+
+
+
+
+ {{ end }}
+ {{ end }}
+