|
1 | 1 | {{- with .cxt}} {{/* Apply proper context from dict */}} |
2 | 2 | {{- if (and .Params.cover.image (not $.isHidden)) }} |
3 | 3 | {{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }} |
| 4 | +{{- $loading := cond $.IsSingle "eager" "lazy" }} |
4 | 5 | <figure class="entry-cover"> |
5 | 6 | {{- $responsiveImages := (.Params.cover.responsiveImages | default site.Params.cover.responsiveImages) | default true }} |
6 | | - {{- $addLink := (and site.Params.cover.linkFullImages (not $.IsHome)) }} |
| 7 | + {{- $addLink := (and site.Params.cover.linkFullImages $.IsSingle) }} |
7 | 8 | {{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }} |
8 | 9 | {{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }} |
9 | 10 | {{- $cover := (or $pageBundleCover $globalResourcesCover)}} |
|
17 | 18 | {{- end -}} |
18 | 19 | {{- $prod := (hugo.IsProduction | or (eq site.Params.env "production")) }} |
19 | 20 | {{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }} |
20 | | - <img loading="lazy" srcset="{{- range $size := $sizes -}} |
| 21 | + <img loading="{{$loading}}" srcset="{{- range $size := $sizes -}} |
21 | 22 | {{- if (ge $cover.Width $size) -}} |
22 | 23 | {{ printf "%s %s" (($cover.Resize (printf "%sx" $size)).Permalink) (printf "%sw ," $size) -}} |
23 | 24 | {{ end }} |
24 | 25 | {{- end -}}{{$cover.Permalink }} {{printf "%dw" ($cover.Width)}}" |
25 | 26 | sizes="(min-width: 768px) 720px, 100vw" src="{{ $cover.Permalink }}" alt="{{ $alt }}" |
26 | 27 | width="{{ $cover.Width }}" height="{{ $cover.Height }}"> |
27 | 28 | {{- else }}{{/* Unprocessable image or responsive images disabled */}} |
28 | | - <img loading="lazy" src="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" alt="{{ $alt }}"> |
| 29 | + <img loading="{{$loading}}" src="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" alt="{{ $alt }}"> |
29 | 30 | {{- end }} |
30 | 31 | {{- else }}{{/* For absolute urls and external links, no img processing here */}} |
31 | 32 | {{- if $addLink }}<a href="{{ (.Params.cover.image) | absURL }}" target="_blank" |
32 | 33 | rel="noopener noreferrer">{{ end -}} |
33 | | - <img loading="lazy" src="{{ (.Params.cover.image) | absURL }}" alt="{{ $alt }}"> |
| 34 | + <img loading="{{$loading}}" src="{{ (.Params.cover.image) | absURL }}" alt="{{ $alt }}"> |
34 | 35 | {{- end }} |
35 | 36 | {{- if $addLink }}</a>{{ end -}} |
36 | 37 | {{/* Display Caption */}} |
37 | | - {{- if not $.IsHome }} |
| 38 | + {{- if $.IsSingle }} |
38 | 39 | {{ with .Params.cover.caption }}<p>{{ . | markdownify }}</p>{{- end }} |
39 | 40 | {{- end }} |
40 | 41 | </figure> |
|
0 commit comments