{{- $img := .src -}} {{- $width := 350 -}} {{- $isRemote := strings.HasPrefix $img "http" -}} {{- $originalImg := "" -}} {{- if not $isRemote -}} {{- $img = .Page.Resources.GetMatch $img -}} {{- if and (not $img) .Page.File -}} {{- $path := path.Join .Page.File.Dir $img -}} {{- $img = resources.Get $path -}} {{- end -}} {{- $originalImg = $img -}} {{/* Resize the image if applicable */}} {{- $img = ($img.Resize (print $width "x")).RelPermalink -}} {{- end -}} {{ with .alt }}{{ . }}{{ else }}{{ .caption | markdownify | plainify }}{{ end }}