2023-08-22 10:14:33 +00:00
{{- $src := $.Page.Resources.GetMatch (.Get "src") -}}
{{- if ( not $src ) -}}
{{- errorf "No Page Resource found for src '%q' (%q)" ( .Get "src" ) .Page.File.Path -}}
2023-02-18 00:38:04 +00:00
{{- end -}}
2023-08-22 10:14:33 +00:00
{{- $linkedResource := $.Page.Resources.GetMatch (.Get "link") -}}
2023-02-18 00:38:04 +00:00
2023-08-22 10:14:33 +00:00
< figure class = "article__figure figure{{ with .Get " class " } } { { . } } { { end } } " role = "group" >
{{- if .Get "link" -}}
{{- if $linkedResource }}
< a href = "{{ $linkedResource.RelPermalink }}" { { with . Get " rel " } } rel = "{{ . }}" { { end } } >
{{ else }}
< a href = "{{ .Get " link " } } " >
{{ end }}
{{- end -}}
2022-11-11 05:48:02 +00:00
2023-08-22 10:14:33 +00:00
{{- if eq $src.ResourceType "image" -}}
< picture class = "figure__picture"
itemprop="image">
< img class = "u-photo figure__image"
{{ if ( or ( eq $src.MediaType.SubType "svg" ) ( eq $src.MediaType.SubType "gif" ) ) }}
src="{{ $src.RelPermalink }}"
{{ else }}
{{ with $src.Resize "1200x webp" }}
src="{{ .RelPermalink }}"
2023-02-18 00:38:04 +00:00
{{ end }}
2023-08-22 10:14:33 +00:00
width="{{ $src.Width }}"
height="{{ $src.Height }}"
{{ end }}
{{- with $src.Params.alt }}
alt="{{ . }}"
2023-02-18 00:38:04 +00:00
{{- end -}}
2023-08-22 10:14:33 +00:00
{{- with $src.Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
role="img"
/>
< / picture >
{{- else if eq $src.ResourceType "video" -}}
{{- if eq $src.MediaType "video/ogg" -}}
< audio class = "u-audio figure__audio" itemprop = "audio" controls >
< source src = "{{ $src.RelPermalink }}" type = "{{ $src.MediaType }}" / >
< p > Your browser doesn't support embedded audio, < a href = "{{ $src.RelPermalink }}" > view the audio here< / a > .< / p >
< / audio >
{{- else -}}
< video class = "u-video figure__video"
controls
src="{{ $src.RelPermalink }}"
poster="
{{- if $src.Params.poster -}}
{{- $posterSrc := $.Page.Resources.GetMatch ( .Get $src.Params.poster ) -}}
{{- with $posterSrc.Resize "1200x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- else -}}
2023-10-03 12:08:35 +00:00
{{- erroridf "a11y-video-poster" "No poster defined for resource %q (%q)" $src.RelPermalink .Page.File.Path -}}
2023-08-22 10:14:33 +00:00
{{- end -}}
"
itemprop="video">
Your browser doesn't support embedded video, < a href = "{{ $src.RelPermalink }}" > view the video here< / a > .
< / video >
2023-02-18 00:38:04 +00:00
{{- end -}}
2023-08-22 10:14:33 +00:00
{{- else if ( or ( ne $src.ResourceType "image" ) ( ne $src.ResourceType "video" ) ) -}}
{{- errorf "No handling for resource of type %q" $src.ResourceType -}}
2023-01-29 18:50:16 +00:00
{{- end -}}
2023-08-22 10:14:33 +00:00
{{- if .Get "link" }}< / a > {{ end -}}
2023-02-18 00:38:04 +00:00
{{- if or ( .Get "caption" ) ( .Get "title" ) ( $src.Params.attr ) -}}
< figcaption class = "figure__caption{{ if not ( or ( .Get " caption " ) ( . Get " title " ) ) } } figure__caption--no-height { { end } } " >
2023-08-22 10:14:33 +00:00
{{- if .Params.attrlink -}}< a class = "figcaption__attrlink" href = "{{ .Params.attrlink }}" > {{- 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 -}}
2023-07-01 03:16:59 +00:00
{{- with .Get "title" -}}< h4 class = "figcaption__title" > {{ . | markdownify | safeHTML }}< / h4 > {{- end -}}
2023-08-22 10:14:33 +00:00
{{- with .Get "caption" -}}< p class = "figcaption__caption" > {{ . | markdownify | safeHTML }}< / p > {{- end -}}
2022-11-11 05:48:02 +00:00
< / figcaption >
{{- end -}}
< / figure >