rimarima/themes/hugo-liftoff/layouts/partials/general/feature-image.html
Adrian Amaglio c09f092db4 init
2023-11-17 10:54:41 +01:00

19 lines
647 B
HTML

{{ $images := $.Resources.ByType "image" -}}
{{ $custom_file := .Params.feature_image }}
{{ $custom_image := $images.GetMatch $custom_file }}
{{ $feature_image := $images.GetMatch "*feature*" -}}
{{ $img_src := "" }}
{{ with $custom_image }}
{{ $img_src = .RelPermalink }}
{{ else }}
{{ with $feature_image }}
{{ $img_src = .RelPermalink }}
{{ end }}
{{ end }}
{{ if $img_src }}
<img class="feature-image"
srcset="{{ $img_src }} 480w, {{ $img_src }} 800w"
sizes="(max-width: 600px) 480px, 800px"
src="{{ $img_src }}"
{{ with $.Params.feature_image_alt }}alt="{{ . }}"{{ else }}alt="Feature image"{{ end }}>
{{ end }}