refactor: resource attribution

This commit is contained in:
Ben Goldsworthy 2025-05-14 17:29:46 +02:00
parent 1a61aeade0
commit 24bfa733ba
No known key found for this signature in database
12 changed files with 169 additions and 99 deletions

View file

@ -9,28 +9,30 @@
{{- $src := . -}}
{{- $isResizable := not ( in ( slice "svg" "gif" ) $src.MediaType.SubType ) -}}
<!-- Rendering -->
<picture
class="picture"
itemprop="image"
>
{{ if $isResizable -}}
<picture
class="picture"
itemprop="image"
>
{{ if $isResizable -}}
<source srcset="{{- ($src.Resize "1200x webp").RelPermalink -}}" />
<source srcset="{{- ($src.Resize "800x png").RelPermalink -}}" media="(max-width: 800px)"/>
{{- end }}
<img
class="u-photo picture__image"
{{ if not $isResizable -}}
src="{{- $src.RelPermalink -}}"
{{- else -}}
src="{{- ($src.Resize "1200x webp").RelPermalink -}}"
width="{{- $src.Width -}}"
height="{{- $src.Height -}}"
{{- end }}
{{ with $src.Params.alt -}}alt="{{- . -}}"{{- end }}
{{ with $src.Params.title -}}title="{{- . -}}" {{- end }}
loading="lazy"
role="img"
<source
srcset="{{- ($src.Resize "800x png").RelPermalink -}}"
media="(max-width: 800px)"
/>
{{- end }}
<img
class="u-photo picture__image"
{{ if not $isResizable -}}
src="{{- $src.RelPermalink -}}"
{{- else -}}
src="{{- ($src.Resize "1200x webp").RelPermalink -}}" width="{{- $src.Width -}}" height="{{- $src.Height -}}"
{{- end }}
{{ with $src.Params.alt -}}alt="{{- . -}}"{{- end }}
{{ with $src.Params.title -}}title="{{- . -}}"{{- end }}
loading="lazy"
role="img"
/>
</picture>