{{ $file := .Get "src" | default (.Get 0) }}
{{ $caption := (.Get "caption" | default (.Get 1)) | markdownify }}
{{ $class := .Get "class" | default (.Get 2) }}
{{ $resize := .Get "resize" | default (.Get 3) }}
{{ $altText := .Get "alt" | default $caption }}
{{ $destination := $file }}
{{ $imgProcConfig := partialCached "utilities/image-processing-config" . }}
{{ $imgPath := .Page.Param "imgPath" }}
{{ if $imgPath }}
{{ $file = path.Join $imgPath $file }}
{{ end }}
{{ $inputFile := .Page.Resources.GetMatch $file }}
{{ with partial "utilities/image-processing" (dict "context" . "input" $inputFile "resize" $resize "config" $imgProcConfig) }}
{{ if .sets.default }}
{{ range .sets.extra }}
{{ end }}
{{ with $caption }}
{{ . }}
{{ end }}
{{ else }}
{{ if .input }}
{{ with $caption }}
{{ . }}
{{ end }}
{{ else }}
{{ with ($destination | safeURL) }}
{{ with $caption }}
{{ . }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}