{{ $url := urls.Parse .src }} {{ $altText := .alt }} {{ $class := .class | default "mx-auto my-0 rounded-md" }} {{ $lazyLoad := .context.Page.Site.Params.enableImageLazyLoading | default true }} {{ $webp := .context.Page.Site.Params.enableWebp | default true }} {{ if findRE "^https?" $url.Scheme }} {{ $altText }} {{ else }} {{ $resource := "" }} {{ if .context.Page.Resources.GetMatch ($url.String) }} {{ $resource = .context.Page.Resources.GetMatch ($url.String) }} {{ else if resources.GetMatch ($url.String) }} {{ $resource = resources.Get ($url.String) }} {{ end }} {{ with $resource }} {{ if (and (ne .MediaType.SubType "svg") $webp) }} {{ end }} {{ $width := ""}} {{ $height := ""}} {{ if eq .MediaType.SubType "svg" }} {{ $svgContent := $resource.Content }} {{ range (findRESubmatch `width=["']?(\d*)` $svgContent 1) }} {{ $width = index . 1 }} {{ end }} {{ range (findRESubmatch `height=["']?(\d*)` $svgContent 1) }} {{ $height = index . 1 }} {{ end }} {{ if (eq "" $width $height) }} {{ range (findRESubmatch `viewBox=["']?(\d*) (\d*) (\d*) (\d*)` $svgContent 1) }} {{ $width = index . 3 }} {{ $height = index . 4 }} {{ end }} {{ end }} {{ else }} {{ $width = .Width }} {{ $height = .Height }} {{ end}} {{ $altText }} {{ else }} {{ $altText }} {{ end }} {{ end }}