{{ $imagePath:= .Get "src" }} {{ $caption:= .Get "caption" }} {{ $position:= .Get "position" }} {{ $class:= .Get "class" }} {{ $height:= replace (replace (.Get "height") "px" "") "x" "" }} {{ $width:= replace (replace (.Get "width") "px" "") "x" "" }} {{ $alt:= .Get "alt" }} {{ $title:= .Get "title" }} {{ $command:= .Get "command" | humanize }} {{ $option:= .Get "option" }} {{ if eq $position `center` }} {{ .Scratch.Set "position" "img-center" }} {{ else if eq $position `left` }} {{ .Scratch.Set "position" "img-left" }} {{ else if eq $position `right` }} {{ .Scratch.Set "position" "img-right" }} {{ else if eq $position `float-left` }} {{ .Scratch.Set "position" "img-float-left" }} {{ else if eq $position `float-right` }} {{ .Scratch.Set "position" "img-float-right" }} {{ end }} {{ if or (hasPrefix $imagePath "http") (fileExists (add `static/` $imagePath)) }} {{ if $caption }}
{{ $alt }}
{{$caption | markdownify}}
{{ else }} {{ $alt }} {{ end }} {{ else }} {{ $contentImage:= .Page.Resources.GetMatch (printf "*%s*" $imagePath) }} {{ $assetImage:= fileExists (add `assets/` $imagePath) }} {{ if or $contentImage $assetImage }} {{ if $contentImage }} {{ .Scratch.Set "image-exists" $contentImage }} {{ else if $assetImage }} {{ .Scratch.Set "image-exists" (resources.Get $imagePath) }} {{ end }} {{ $image:= .Scratch.Get "image-exists" }} {{ $imageExt := path.Ext $image }} {{ if eq $imageExt `.svg` }} {{ .Scratch.Set "image-height" "" }} {{ .Scratch.Set "image-width" "" }} {{ else }} {{ .Scratch.Set "image-height" $image.Height }} {{ .Scratch.Set "image-width" $image.Width }} {{ end }} {{ $imageHeight:= .Scratch.Get "image-height" }} {{ $imageWidth:= .Scratch.Get "image-width" }} {{ if or (eq $imageExt `.gif`) (eq $imageExt `.svg`) }} {{ .Scratch.Set `image` $image.RelPermalink }} {{ else }} {{ $options:= add (add (add (add (string ($width | default $imageWidth)) "x") (string ($height | default $imageHeight))) " webp ") (string $option) }} {{ if eq $command `Fit` }} {{ .Scratch.Set `image` ($image.Fit $options).RelPermalink }} {{ .Scratch.Set `fallback` ($image.Fit (replace $options `webp` ``)).RelPermalink }} {{ else if eq $command `Fill` }} {{ .Scratch.Set `image` ($image.Fill $options).RelPermalink }} {{ .Scratch.Set `fallback` ($image.Fill (replace $options `webp` ``)).RelPermalink }} {{ else }} {{ .Scratch.Set `image` ($image.Resize $options).RelPermalink }} {{ .Scratch.Set `fallback` ($image.Resize (replace $options `webp` ``)).RelPermalink }} {{ end }} {{ end }} {{ if $caption }}
{{$alt}}
{{$caption | markdownify}}
{{ else }} {{$alt}} {{ end }} {{ else }} {{site.BaseURL}}{{$imagePath}} does not exist {{ end }} {{ end }}