{{- /* Determine content path for error messages. */}} {{- $path := "" }} {{- with .Page.File }} {{- $path = .Path }} {{- else }} {{- $path = .Path }} {{- end }} {{- /* Get image resource. */}} {{- $u := urls.Parse .Destination }} {{- $r := "" }} {{- if $u.IsAbs }} {{- with resources.GetRemote $u.String }} {{- with .Err }} {{- errorf "Unable to get remote image %s: %s. See %s" $u.String . $path }} {{- else }} {{- /* Image is a global resource (remote). */}} {{- $r = . }} {{- end }} {{- else }} {{- errorf "Unable to get remote image %s. See %s" $u.String $path }} {{- end }} {{- else }} {{- with .Page.Resources.Get $u.Path }} {{- /* Image is a page resource. */}} {{- $r = . }} {{- else }} {{- with resources.Get $u.Path }} {{- /* Image is a global resource (local). */}} {{- $r = . }} {{- else }} {{- errorf "Unable to get image %s. See %s" $u.Path $path }} {{- end }} {{- end }} {{- end }} {{- if $r }} {{- /* Set image element attributes. */}} {{- $attributes := dict "src" $r.RelPermalink "loading" "lazy" "width" (string $r.Width) "height" (string $r.Height) }} {{- with .PlainText }} {{- $attributes = merge $attributes (dict "alt" .) }} {{- end }} {{- with .Title }} {{- $attributes = merge $attributes (dict "title" .) }} {{- end }} {{- /* Render image element. */ -}} {{if .IsBlock -}} {{ with .Title -}} {{ . }} {{- end }} {{ else }} {{ end }} {{- end -}}
{{ . }}