mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-04 20:30:44 +00:00
43 lines
1.4 KiB
HTML
43 lines
1.4 KiB
HTML
{{ $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
|
{{ $customAlt := .Get "alt" }}
|
|
{{ $customSize := .Get "size" }}
|
|
{{ $lazyLoad := default (default true $.Site.Params.GeekblogImageLazyLoading) (.Get "lazy") }}
|
|
|
|
{{ with $source }}
|
|
{{ $caption := default .Title $customAlt }}
|
|
|
|
{{ $tiny := (.Resize "320x").Permalink }}
|
|
{{ $small := (.Resize "600x").Permalink }}
|
|
{{ $medium := (.Resize "1200x").Permalink }}
|
|
{{ $large := (.Resize "1800x").Permalink }}
|
|
|
|
{{ $size := dict "tiny" $tiny "small" $small "medium" $medium "large" $large }}
|
|
|
|
|
|
<div class="flex justify-center">
|
|
<figure class="gblog-post__figure">
|
|
<a class="gblog-markdown__link--raw" href="{{ .Permalink }}">
|
|
<picture>
|
|
<source
|
|
{{ with $customSize }}
|
|
srcset="{{ index $size $customSize }}"
|
|
{{ else }}
|
|
srcset="{{ $size.small }} 600w, {{ $size.medium }} 1200w" sizes="100vw"
|
|
{{ end }}
|
|
/>
|
|
<img
|
|
{{ if $lazyLoad }}loading="lazy"{{ end }}
|
|
src="{{ $size.large }}"
|
|
alt="{{ $caption }}"
|
|
/>
|
|
</picture>
|
|
</a>
|
|
{{ with $caption }}
|
|
<figcaption>
|
|
{{ . }}{{ with $source.Params.credits }}({{ . | $.Page.RenderString }}){{ end }}
|
|
</figcaption>
|
|
{{ end }}
|
|
</figure>
|
|
</div>
|
|
{{ end }}
|