Omphaloskepsis-2/layouts/shortcodes/gallery_new.html
2023-06-30 21:16:59 -06:00

79 lines
3.6 KiB
HTML

<figure class="figure--gallery gallery" itemscope itemtype="http://schema.org/ImageGallery">
{{- if or ( .Get "caption" ) ( .Get "title" ) -}}
<figcaption class="figure__caption gallery__caption{{ if not ( or ( .Get "caption" ) ( .Get "title" ) ) }} figure__caption--no-height{{ end }}">
{{- with .Get "title" -}}<h4 class="figcaption__title">{{ . | markdownify | safeHTML }}</h4>{{- end -}}
{{- with .Get "caption" -}}
<p class="figcaption__caption">{{ . | markdownify | safeHTML }}</p>
{{- end -}}
</figcaption>
{{- end -}}
{{- with (.Get "dir") -}}
<!-- If a directory was specified, generate figures for all of the images in the directory -->
{{- $images := $.Page.Resources.Match ( print . "/*" ) }}
{{- range $images -}}
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
{{- $linkURL := print $.Page.Permalink ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
<figure class="figure gallery__figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="{{ .RelPermalink }}" itemprop="contentUrl">
<picture class="figure__picture"
itemprop="image">
<img itemprop="thumbnail"
class="u-photo gallery__thumbnail"
{{ if ( or ( eq .MediaType.SubType "svg" ) ( eq .MediaType.SubType "gif" ) ) }}
src="{{ .RelPermalink }}"
{{ else }}
{{ with .Resize "600x webp" }}
src="{{ .RelPermalink }}"
{{ end }}
width="{{ .Width }}"
height="{{ .Height }}"
{{ end }}
{{- with .Params.alt }}
alt="{{ . }}"
{{- end -}}
{{- with .Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
>
</picture>
</a>
{{- if or ( .Params.title ) ( .Params.attr ) -}}
<figcaption class="figure__caption{{ if not .Params.title }} figure__caption--no-height{{ end }}">
{{ if .Params.attrlink -}}
<a class="figcaption__attrlink" href="{{ .Params.attrlink }}"
{{- with .Params.attrtarget }} target="{{ . }}"{{ end -}}
{{- with .Params.attrrel }} rel="{{ . }}"{{ end -}}
>
{{- end -}}
{{- if .Params.attr -}}<p class="figcaption__attr">{{ .Params.attr | safeHTML }}{{ with .Params.attrlicence }} <span class="figcaption__licence">{{ . | safeHTML }}</span>{{ end }}</p>{{- end -}}
{{- if .Params.attrlink -}}
</a>
{{- end -}}
{{- if .Params.href -}}
<a href="{{- if ( eq .Params.href "asCite" ) -}}{{ .Params.cite }}{{- else -}}{{ .Params.href }}{{- end -}}">
{{- end -}}
{{- if .Params.title -}}
<h5 class="figcaption__title">
{{- if .Params.titleLang -}}
<i lang="{{ .Params.titleLang }}" title="{{ .Params.titleTr }}">
{{- end -}}
{{ .Params.title | safeHTML }}
{{- if .Params.titleLang -}}
</i>
{{- end -}}
</h5>
{{- else -}}
<p class="figcaption__title">Link</p>
{{- end -}}
{{- if .Params.href -}}
</a>
{{- end -}}
</figcaption>
{{- end -}}
</figure>
{{- end }}
{{- else -}}
<!-- If no directory was specified, include any figure shortcodes called within the gallery -->
{{ .Inner }}
{{- end }}
</figure>