cremeaux/layouts/shortcodes/gallery.html

33 lines
1.1 KiB
HTML
Raw Permalink Normal View History

{{ $baseURL := .Page.RelPermalink }}
{{ $resources := .Page.Resources }}
</div>
</div>
2022-02-02 17:38:21 +01:00
{{ $images := split (trim .Inner "\n") "!" }}
{{ $patternTitle := "\\[([^]]*)\\]\\(.*\\)" }}
{{ $patternPath := "\\[.*\\]\\(([^)]*)\\)" }}
<div class="masonry" itemscope itemtype="http://schema.org/ImageGallery">
2022-02-02 17:38:21 +01:00
{{ range $images }}
{{ with . }}
{{ $title := replaceRE $patternTitle "$1" . }}
{{ $path := trim (replaceRE $patternPath "$1" .) " \n" }}
<figure itemscope class="brick" itemtype="http://schema.org/ImageObject">
{{ $image := $resources.GetMatch (printf "*%s*" $path) }}
{{ $orientation := 1 }}
{{ with $image }}{{ with .Exif }}{{ $orientation = .Tags.Orientation }}{{ end }}{{ end }}
{{ if eq $orientation 8 }}
{{ $image = $image.Resize "300x r90" }}
{{ else if eq $orientation 6 }}
{{ $image = $image.Resize "300x r270" }}
{{ end }}
{{ $resized := $image.Resize "300x q100 webp" }}
2022-02-02 17:38:21 +01:00
<img src="{{ $resized.RelPermalink }}" alt="{{ $title }}" title="{{ $title }}" loading="lazy">
</figure>
{{ end }}
2022-02-02 17:38:21 +01:00
{{ end }}
</div>
<div class="container">
<div class="container news md">