2023-08-22 11:14:33 +01:00
< 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 -}}
2023-01-29 13:50:16 -05:00
{{- with (.Get "dir") -}}
<!-- If a directory was specified, generate figures for all of the images in the directory -->
2025-05-05 21:27:09 +02:00
{{- $resources := $.Page.Resources.Match ( print . "/*" ) }}
{{- range $resources -}}
2023-08-22 11:14:33 +01:00
{{- $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" >
2025-05-05 21:27:09 +02:00
{{- if eq .ResourceType "image" -}}
< picture class = "figure__picture"
2023-08-22 11:14:33 +01:00
itemprop="image">
2025-05-05 21:27:09 +02:00
< img itemprop = "thumbnail"
class="u-photo gallery__thumbnail"
{{ if ( or ( eq .MediaType.SubType "svg" ) ( eq .MediaType.SubType "gif" ) ) }}
2023-08-22 11:14:33 +01:00
src="{{ .RelPermalink }}"
2025-05-05 21:27:09 +02:00
{{ else }}
{{ with .Resize "600x webp" }}
src="{{ .RelPermalink }}"
{{ end }}
width="{{ .Width }}"
height="{{ .Height }}"
2023-08-22 11:14:33 +01:00
{{ end }}
2025-05-05 21:27:09 +02:00
{{- with .Params.alt }}
alt="{{ . }}"
{{- end -}}
{{- with .Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
>
< / picture >
{{- else if eq .ResourceType "video" -}}
{{- if eq .MediaType "video/ogg" -}}
{{- partial "media/audio.html" . -}}
{{- else -}}
{{- partial "media/video.html" ( dict "src" . "page_file_path" $.Page.File.Path ) -}}
{{- end -}}
{{- else if ( or ( ne .ResourceType "image" ) ( ne .ResourceType "video" ) ) -}}
{{- errorf "No handling for resource of type %q" .ResourceType -}}
{{- end -}}
2023-08-22 11:14:33 +01:00
< / 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 -}}
{{- with .Params.href -}}
< p class = "figcaption__title" > Link< / p >
{{- end -}}
{{- end -}}
{{- if .Params.href -}}
< / a >
{{- end -}}
< / figcaption >
{{- end -}}
< / figure >
2023-01-29 13:50:16 -05:00
{{- end }}
{{- else -}}
<!-- If no directory was specified, include any figure shortcodes called within the gallery -->
{{ .Inner }}
{{- end }}
2023-08-22 11:14:33 +01:00
< / figure >