Allow emabling/disabling responsiveImages per page #518
This commit is contained in:
parent
2aad433ae5
commit
5bc9c5a73b
@ -2,6 +2,7 @@
|
||||
{{- if (and .Params.cover.image (not $.isHidden)) }}
|
||||
{{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }}
|
||||
<figure class="entry-cover">
|
||||
{{- $responsiveImages := (.Params.cover.responsiveImages | default .Site.Params.cover.responsiveImages) | default true }}
|
||||
{{- $addLink := (and .Site.Params.cover.linkFullImages (not $.IsHome)) }}
|
||||
{{- $cover := (.Page.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
||||
{{- if $cover -}}{{/* i.e it is present in page bundle */}}
|
||||
@ -10,7 +11,7 @@
|
||||
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
|
||||
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") }}
|
||||
{{- $prod := (hugo.IsProduction | or (eq .Site.Params.env "production")) }}
|
||||
{{- if (and (in $processableFormats $cover.MediaType.SubType) (ne .Site.Params.cover.responsiveImages false) (eq $prod true)) }}
|
||||
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
|
||||
<img loading="lazy" srcset="{{- range $size := $sizes -}}
|
||||
{{- if (ge $cover.Width $size) -}}
|
||||
{{ printf "%s %s" (($cover.Resize (printf "%sx" $size)).Permalink) (printf "%sw ," $size) -}}
|
||||
|
Loading…
Reference in New Issue
Block a user