File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {{ $alt := .Text | default "" }}
2+ {{ $title := .Title | default $alt }}
3+ {{ $src := .Destination | safeURL }}
4+ {{ with .Page.Resources.GetMatch $src }}
5+ < figure >
6+ {{ partial "_images/picture.html" (dict "src" . "alt" $alt "title" $title) }}
7+ {{ with $alt }}< figcaption >
8+ < p style ="text-transform: uppercase; font-size: x-small; "> {{- . -}}</ p >
9+ </ figcaption > {{ end }}
10+ </ figure >
11+ {{ end }}
Original file line number Diff line number Diff line change 1+ {{ $originalImage := .src }}
2+ {{ $class := .class }}
3+ {{ $lazy := .lazy | default true }}
4+ {{ $caption := .alt | default "" }}
5+
6+ {{ $w := float $originalImage.Width }}
7+ {{ $h := float $originalImage.Height }}
8+ {{ $aspectRatio := div $w $h }}
9+
10+ {{ $media_query_widths := slice 1400 1200 992 768 576 480 360}}
11+
12+ < picture >
13+ {{ range $media_query_widths }}
14+ {{ $nw := . }}
15+ {{ $nh := div $nw $aspectRatio | int }}
16+ {{ $img_webp := $originalImage.Resize (printf "%dx%d webp q100" $nw $nh) }}
17+ < source media ="(min-width:{{$nw}}px) " srcset ="{{ $img_webp.Permalink }} " type ="image/webp ">
18+ {{end}}
19+ < img {{with $lazy}} loading ="lazy " class ="img-fluid " data-src ="{{$originalImage.RelPermalink}} " {{else}}
20+ src ="{{$originalImage.RelPermalink}} " {{end}} alt ="{{ $caption }} ">
21+ </ picture >
You can’t perform that action at this time.
0 commit comments