github.com/square/finch@v0.0.0-20240412205204-6530c03e2b96/docs/themes/hugo-geekdoc/layouts/shortcodes/img.html (about) 1 {{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }} 2 {{- $customAlt := .Get "alt" }} 3 {{- $customSize := .Get "size" | lower }} 4 {{- $lazyLoad := default (default true $.Site.Params.GeekdocImageLazyLoading) (.Get "lazy") }} 5 {{- $data := newScratch }} 6 7 {{- with $source }} 8 {{- $caption := default .Title $customAlt }} 9 {{- $isSVG := (eq .MediaType.SubType "svg") }} 10 11 {{- $origin := .Permalink }} 12 {{- if $isSVG }} 13 {{- $data.SetInMap "size" "profile" "180" }} 14 {{- $data.SetInMap "size" "tiny" "320" }} 15 {{- $data.SetInMap "size" "small" "600" }} 16 {{- $data.SetInMap "size" "medium" "1200" }} 17 {{- $data.SetInMap "size" "large" "1800" }} 18 {{- else }} 19 {{- $data.SetInMap "size" "profile" (.Fill "180x180 Center").Permalink }} 20 {{- $data.SetInMap "size" "tiny" (.Resize "320x").Permalink }} 21 {{- $data.SetInMap "size" "small" (.Resize "600x").Permalink }} 22 {{- $data.SetInMap "size" "medium" (.Resize "1200x").Permalink }} 23 {{- $data.SetInMap "size" "large" (.Resize "1800x").Permalink }} 24 {{- end }} 25 26 27 <div class="flex justify-center"> 28 <figure 29 class="gdoc-markdown__figure 30 {{- if eq $customSize "profile" }}{{ print " gdoc-post__figure--round" }}{{ end }}" 31 > 32 <a class="gdoc-markdown__link--raw" href="{{ .Permalink }}"> 33 <picture> 34 {{- $size := $data.Get "size" }} 35 {{- if not $isSVG }} 36 <source 37 {{- with $customSize }} 38 srcset="{{ index $size $customSize }}" 39 {{- else }} 40 srcset="{{ $size.small }} 600w, {{ $size.medium }} 1200w" sizes="100vw" 41 {{- end }} 42 /> 43 {{- end }} 44 <img 45 {{- if $isSVG }} 46 src="{{ $origin }}" width="{{ index $size (default "medium" $customSize) }}" 47 {{- else }} 48 {{- if $lazyLoad }}{{ print " loading=\"lazy\"" | safeHTMLAttr }}{{- end }} 49 {{- if eq $customSize "origin" }} 50 src="{{ $origin }}" 51 {{- else }} 52 src="{{ $size.large }}" 53 {{- end }} 54 alt="{{ $caption }}" 55 {{- end }} 56 /> 57 </picture> 58 </a> 59 {{- if not (eq $customSize "profile") }} 60 {{- with $caption }} 61 <figcaption> 62 {{ . }} 63 {{- with $source.Params.credits }} 64 {{ printf " (%s)" . | $.Page.RenderString }} 65 {{- end }} 66 </figcaption> 67 {{- end }} 68 {{- end }} 69 </figure> 70 </div> 71 {{- end }}