2022-07-11 13:46:49 +00:00
|
|
|
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
|
|
|
{{- $customAlt := .Get "alt" }}
|
|
|
|
{{- $customSize := .Get "size" | lower }}
|
2023-06-22 08:52:32 +00:00
|
|
|
{{- $lazyLoad := default (default true $.Site.Params.geekblogImageLazyLoading) (.Get "lazy") }}
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- $data := newScratch }}
|
2020-07-27 18:17:55 +00:00
|
|
|
|
2022-07-11 13:46:49 +00:00
|
|
|
{{- with $source }}
|
|
|
|
{{- $caption := default .Title $customAlt }}
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- $isSVG := (eq .MediaType.SubType "svg") }}
|
2020-07-27 18:17:55 +00:00
|
|
|
|
2022-09-02 09:22:48 +00:00
|
|
|
{{- $origin := .Permalink }}
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- if $isSVG }}
|
|
|
|
{{- $data.SetInMap "size" "profile" "180" }}
|
|
|
|
{{- $data.SetInMap "size" "tiny" "320" }}
|
|
|
|
{{- $data.SetInMap "size" "small" "600" }}
|
|
|
|
{{- $data.SetInMap "size" "medium" "1200" }}
|
|
|
|
{{- $data.SetInMap "size" "large" "1800" }}
|
|
|
|
{{- else }}
|
2023-12-02 15:42:30 +00:00
|
|
|
{{- $data.SetInMap "size" "profile" (.Fill "180x180 Smart").Permalink }}
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- $data.SetInMap "size" "tiny" (.Resize "320x").Permalink }}
|
|
|
|
{{- $data.SetInMap "size" "small" (.Resize "600x").Permalink }}
|
|
|
|
{{- $data.SetInMap "size" "medium" (.Resize "1200x").Permalink }}
|
|
|
|
{{- $data.SetInMap "size" "large" (.Resize "1800x").Permalink }}
|
|
|
|
{{- end }}
|
2020-07-27 18:17:55 +00:00
|
|
|
|
2021-12-30 14:55:55 +00:00
|
|
|
|
|
|
|
<div class="flex justify-center">
|
2022-07-11 13:46:49 +00:00
|
|
|
<figure
|
|
|
|
class="gblog-post__figure
|
|
|
|
{{- if eq $customSize "profile" }}{{ print " gblog-post__figure--round" }}{{ end }}"
|
|
|
|
>
|
2022-02-06 22:57:32 +00:00
|
|
|
<a class="gblog-markdown__link--raw" href="{{ .Permalink }}">
|
2021-05-23 20:42:47 +00:00
|
|
|
<picture>
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- $size := $data.Get "size" }}
|
|
|
|
{{- if not $isSVG }}
|
|
|
|
<source
|
|
|
|
{{- with $customSize }}
|
|
|
|
srcset="{{ index $size $customSize }}"
|
|
|
|
{{- else }}
|
|
|
|
srcset="{{ $size.small }} 600w, {{ $size.medium }} 1200w" sizes="100vw"
|
|
|
|
{{- end }}
|
|
|
|
/>
|
|
|
|
{{- end }}
|
2021-12-30 14:55:55 +00:00
|
|
|
<img
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- if $isSVG }}
|
|
|
|
src="{{ $origin }}" width="{{ index $size (default "medium" $customSize) }}"
|
2022-09-02 09:22:48 +00:00
|
|
|
{{- else }}
|
2022-12-21 14:43:57 +00:00
|
|
|
{{- if $lazyLoad }}{{ print " loading=\"lazy\"" | safeHTMLAttr }}{{- end }}
|
|
|
|
{{- if eq $customSize "origin" }}
|
|
|
|
src="{{ $origin }}"
|
|
|
|
{{- else }}
|
|
|
|
src="{{ $size.large }}"
|
|
|
|
{{- end }}
|
|
|
|
alt="{{ $caption }}"
|
2022-09-02 09:22:48 +00:00
|
|
|
{{- end }}
|
2021-12-30 14:55:55 +00:00
|
|
|
/>
|
2021-05-23 20:42:47 +00:00
|
|
|
</picture>
|
2021-12-30 14:55:55 +00:00
|
|
|
</a>
|
2022-07-11 13:46:49 +00:00
|
|
|
{{- if not (eq $customSize "profile") }}
|
|
|
|
{{- with $caption }}
|
|
|
|
<figcaption>
|
|
|
|
{{ . }}
|
|
|
|
{{- with $source.Params.credits }}
|
|
|
|
{{ printf " (%s)" . | $.Page.RenderString }}
|
|
|
|
{{- end }}
|
|
|
|
</figcaption>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2021-12-30 14:55:55 +00:00
|
|
|
</figure>
|
|
|
|
</div>
|
2022-07-11 13:46:49 +00:00
|
|
|
{{- end }}
|