2026-04-08 19:49:15 +02:00
|
|
|
{{- /*
|
|
|
|
|
Renders an image or video from a front matter map.
|
|
|
|
|
|
|
|
|
|
Usage:
|
2026-05-08 13:18:05 +02:00
|
|
|
{{ partial "media.html" (dict "media" .Params.banner "class" "w-full h-full object-cover")
|
|
|
|
|
}}
|
2026-04-08 19:49:15 +02:00
|
|
|
|
2026-05-08 13:18:05 +02:00
|
|
|
Parameters: media — map with keys: type (image|video), src, alt class — CSS classes applied to the img/video element
|
|
|
|
|
lazy — set to false to disable lazy loading (default true) */ -}}
|
2026-04-08 19:49:15 +02:00
|
|
|
{{- $media := .media -}}
|
|
|
|
|
{{- $class := .class | default "" -}}
|
|
|
|
|
{{- $lazy := .lazy | default true -}}
|
|
|
|
|
|
|
|
|
|
{{- with $media -}}
|
|
|
|
|
{{- if eq .type "video" -}}
|
2026-05-08 13:18:05 +02:00
|
|
|
<video
|
|
|
|
|
class="{{ $class }}"
|
|
|
|
|
src="{{ .src }}"
|
|
|
|
|
autoplay
|
|
|
|
|
loop
|
|
|
|
|
muted
|
|
|
|
|
playsinline
|
|
|
|
|
{{- with .alt }}aria-label="{{ . }}"{{ end }}
|
|
|
|
|
></video>
|
2026-04-08 19:49:15 +02:00
|
|
|
{{- else -}}
|
2026-05-08 13:18:05 +02:00
|
|
|
<img
|
|
|
|
|
class="{{ $class }}"
|
|
|
|
|
src="{{ .src }}"
|
|
|
|
|
alt="{{ .alt | default "" }}"
|
|
|
|
|
{{- if $lazy }}loading="lazy" decoding="async"{{ end }}
|
|
|
|
|
/>
|
2026-04-08 19:49:15 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
{{- end -}}
|