{{ $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=["']([.0-9]*)["'a-zA-Z]` $svgContent 1) }} {{ $width = index . 1 }} {{ end }} {{ range (findRESubmatch `]*height=["']([.0-9]*)["'a-zA-Z]` $svgContent 1) }} {{ $height = index . 1 }} {{ end }} {{ if (eq "" $width $height) }} {{ range (findRESubmatch `]*viewBox=["']?([.0-9]*) ([.0-9]*) ([.0-9]*) ([.0-9]*)` $svgContent 1) }} {{ $width = index . 3 }} {{ $height = index . 4 }} {{ end }} {{ end }} {{ else }} {{ $width = .Width }} {{ $height = .Height }} {{ end}} {{ $altText }} {{ else }} {{ $altText }} {{ end }} {{ end }}