Back to Distribution

Img

docs/themes/hugo-geekdoc/layouts/shortcodes/img.html

3.1.11.1 KB
Original Source

{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }} {{- $customAlt := .Get "alt" }} {{- $customSize := .Get "size" | lower }} {{- $lazyLoad := default (default true $.Site.Params.geekdocImageLazyLoading) (.Get "lazy") }} {{- $data := newScratch }} {{- with $source }} {{- $caption := default .Title $customAlt }} {{- $isSVG := (eq .MediaType.SubType "svg") }} {{- $origin := . }} {{- if $isSVG }} {{- $data.SetInMap "size" "tiny" "320" }} {{- $data.SetInMap "size" "small" "600" }} {{- $data.SetInMap "size" "medium" "1200" }} {{- $data.SetInMap "size" "large" "1800" }} {{- else }} {{- $data.SetInMap "size" "tiny" "320x"}} {{- $data.SetInMap "size" "small" "600x" }} {{- $data.SetInMap "size" "medium" "1200x" }} {{- $data.SetInMap "size" "large" "1800x" }} {{- end -}}

{{- $size := $data.Get "size" }} {{- if not $isSVG }} {{- if ne $customSize "origin" }} {{- end }} {{- end }} {{- with $caption }} {{ . }} {{- with $source.Params.credits }} {{ printf " (%s)" . | $.Page.RenderString }} {{- end }} {{- end }}

{{- end }}