{{ if .caption }}
{{ end }} {{ if (strings.HasPrefix .src "http") }} {{ .alt }} {{ else if (strings.HasPrefix .src "/") }} {{ $imageConfig := imageConfig (path.Join "static" .src) }} {{ .alt }} {{ else }} {{ $src := .src }} {{ if strings.HasPrefix $src "./" }} {{ $src = substr $src 2 }} {{ end }} {{ $images := .page.Resources.ByType "image" }} {{ $image := $images.GetMatch $src }} {{ if eq $image.MediaType.SubType "svg" }} {{ .alt }} {{ else }} {{ $minWidth := .page.Site.Params.imageResize.min | default 300 }} {{ $maxWidth := .page.Site.Params.imageResize.max | default 700 }} {{ $increment := .page.Site.Params.imageResize.increment | default 200 }} {{ $widths := seq $minWidth $increment $maxWidth }} {{ if lt $image.Width $maxWidth }} {{ $widths = $widths | append $image.Width }} {{ end }} {{ $widthsCount := len $widths }} {{ $sizes := slice }} {{ $srcSet := slice }} {{ $webpSrcSet := slice }} {{ range $i, $width := $widths }} {{ if ge $image.Width $width }} {{ if eq $i (sub $widthsCount 1) }} {{ $sizes = $sizes | append (printf "%dpx" $width) }} {{ else }} {{ $maxWidth := (add $width (sub $increment 1)) }} {{ $sizes = $sizes | append (printf "(max-width: %dpx) %dpx" $maxWidth $width) }} {{ end }} {{ $resized := $image.Resize (printf "%dx" $width) }} {{ $srcSet = $srcSet | append (printf "%s %dw" $resized.RelPermalink $resized.Width) }} {{ if not (eq "webp" $image.MediaType.SubType) }} {{ $webp := $image.Resize (printf "%dx webp" $width) }} {{ $webpSrcSet = $webpSrcSet | append (printf "%s %dw" $webp.RelPermalink $webp.Width) }} {{ end }} {{ end }} {{ end }} {{ .alt }} {{ end }} {{ end }} {{ if .caption }}
{{ .page.RenderString .caption }}
{{ end }}