File tree Expand file tree Collapse file tree
themes/hugo-PaperMod/layouts/shortcodes Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11< figure style ="text-align: center; margin: 20px 0; ">
2- < img src ="{{ .Get "src " }}" alt="{{ .Get "alt " }}" style="width: {{ .Get "width " | default "80%" }}; height: auto; display: block; margin: 0 auto;" />
3- < figcaption style ="font-size: 14px; color: #666; font-style: italic; margin-top: 8px; "> {{ .Inner | markdownify }}</ figcaption >
4- </ figure >
2+ {{ $src := .Get "src" }}
3+ {{ $convertToWebp := .Get "webp" }}
4+ {{ if and $convertToWebp (eq $convertToWebp "true") (.Page.Resources.Get $src) }}
5+ {{ $image := .Page.Resources.Get $src }}
6+ {{ $size := .Get "size" | default "800x" }}
7+ {{ $quality := .Get "quality" | default "75" }}
8+ {{ $processed := $image.Resize (printf "%s webp q%s" $size $quality) }}
9+ < img loading ="lazy " src ="{{ $processed.RelPermalink }} "
10+ alt ="{{ .Get "alt " }}"
11+ {{- with .Get "width" }} width="{{ . }} "{{ end -}}
12+ {{- with .Get "height" }} height="{{ . }} "{{ end -}}
13+ style ="height: auto; display: block; margin: 0 auto; " />
14+ {{ else }}
15+ < img loading ="lazy " src ="{{ $src }} "
16+ alt ="{{ .Get "alt " }}"
17+ {{- with .Get "width" }} width="{{ . }} "{{ end -}}
18+ {{- with .Get "height" }} height="{{ . }} "{{ end -}}
19+ style ="height: auto; display: block; margin: 0 auto; " />
20+ {{ end }}
21+ < figcaption style ="font-size: 14px; color: #666; font-style: italic; margin-top: 8px; "> {{ .Inner | markdownify }}</ figcaption >
22+ </ figure >
You can’t perform that action at this time.
0 commit comments