2022-07-11 20:46:07 +02:00
|
|
|
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
|
|
|
{{- $customAlt := .Get "alt" }}
|
|
|
|
{{- $customSize := .Get "size" | lower }}
|
2023-06-22 09:45:54 +02:00
|
|
|
{{- $lazyLoad := default (default true $.Site.Params.geekdocImageLazyLoading) (.Get "lazy") }}
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- $data := newScratch }}
|
2021-02-20 21:39:31 +01:00
|
|
|
|
2022-07-11 20:46:07 +02:00
|
|
|
{{- with $source }}
|
|
|
|
{{- $caption := default .Title $customAlt }}
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- $isSVG := (eq .MediaType.SubType "svg") }}
|
2021-02-20 21:39:31 +01:00
|
|
|
|
2024-04-07 20:15:01 +02:00
|
|
|
{{- $origin := . }}
|
2022-12-21 15:53:02 +01:00
|
|
|
{{- if $isSVG }}
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- $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" }}
|
2022-12-21 15:53:02 +01:00
|
|
|
{{- else }}
|
2024-04-07 20:15:01 +02:00
|
|
|
{{- $data.SetInMap "size" "profile" "180x180 Center" }}
|
|
|
|
{{- $data.SetInMap "size" "tiny" "320x"}}
|
|
|
|
{{- $data.SetInMap "size" "small" "600x" }}
|
|
|
|
{{- $data.SetInMap "size" "medium" "1200x" }}
|
|
|
|
{{- $data.SetInMap "size" "large" "1800x" }}
|
2022-12-21 15:53:02 +01:00
|
|
|
{{- end }}
|
2021-02-20 21:39:31 +01:00
|
|
|
|
2022-01-06 13:58:10 +01:00
|
|
|
|
|
|
|
<div class="flex justify-center">
|
2022-07-11 20:46:07 +02:00
|
|
|
<figure
|
2022-09-02 10:58:44 +02:00
|
|
|
class="gdoc-markdown__figure
|
2024-04-07 20:15:01 +02:00
|
|
|
{{- if eq $customSize "profile" }}{{ print " gdoc-markdown__figure--round" }}{{ end }}"
|
2022-07-11 20:46:07 +02:00
|
|
|
>
|
2022-02-07 13:24:00 +01:00
|
|
|
<a class="gdoc-markdown__link--raw" href="{{ .Permalink }}">
|
2021-04-27 23:44:35 +02:00
|
|
|
<picture>
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- $size := $data.Get "size" }}
|
|
|
|
{{- if not $isSVG }}
|
2024-04-07 20:15:01 +02:00
|
|
|
{{- if ne $customSize "origin" }}
|
2022-12-11 15:05:30 +01:00
|
|
|
<source
|
|
|
|
{{- with $customSize }}
|
2024-04-07 20:15:01 +02:00
|
|
|
{{- if eq $customSize "profile" }}
|
|
|
|
srcset="{{ ($origin.Fill (index $size $customSize)).Permalink }}"
|
|
|
|
{{- else}}
|
|
|
|
srcset="{{ ($origin.Resize (index $size $customSize)).Permalink }}"
|
|
|
|
{{- end}}
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- else }}
|
2024-04-07 20:15:01 +02:00
|
|
|
srcset="{{ ($origin.Resize (index $size "small")).Permalink }} 600w, {{ ($origin.Resize (index $size "medium")).Permalink }} 1200w" sizes="100vw"
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- end }}
|
|
|
|
/>
|
2024-04-07 20:15:01 +02:00
|
|
|
{{- end }}
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- end }}
|
2022-01-06 13:58:10 +01:00
|
|
|
<img
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- if $isSVG }}
|
2024-04-07 20:15:01 +02:00
|
|
|
src="{{ $origin.Permalink }}" width="{{ index $size (default "medium" $customSize) }}"
|
2022-09-02 10:58:44 +02:00
|
|
|
{{- else }}
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- if $lazyLoad }}{{ print " loading=\"lazy\"" | safeHTMLAttr }}{{- end }}
|
|
|
|
{{- if eq $customSize "origin" }}
|
2024-04-07 20:15:01 +02:00
|
|
|
src="{{ $origin.Permalink }}"
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- else }}
|
2024-04-07 20:15:01 +02:00
|
|
|
src="{{ ($origin.Resize (index $size "large")).Permalink }}"
|
2022-12-11 15:05:30 +01:00
|
|
|
{{- end }}
|
|
|
|
alt="{{ $caption }}"
|
2022-09-02 10:58:44 +02:00
|
|
|
{{- end }}
|
2022-01-06 13:58:10 +01:00
|
|
|
/>
|
2021-04-27 23:44:35 +02:00
|
|
|
</picture>
|
2022-01-06 13:58:10 +01:00
|
|
|
</a>
|
2022-07-11 20:46:07 +02:00
|
|
|
{{- if not (eq $customSize "profile") }}
|
|
|
|
{{- with $caption }}
|
|
|
|
<figcaption>
|
|
|
|
{{ . }}
|
|
|
|
{{- with $source.Params.credits }}
|
|
|
|
{{ printf " (%s)" . | $.Page.RenderString }}
|
|
|
|
{{- end }}
|
|
|
|
</figcaption>
|
|
|
|
{{- end }}
|
2022-01-06 13:58:10 +01:00
|
|
|
{{- end }}
|
|
|
|
</figure>
|
|
|
|
</div>
|
2022-07-11 20:46:07 +02:00
|
|
|
{{- end }}
|