diff options
| author | Aditya Telange <21258296+adityatelange@users.noreply.github.com> | 2021-09-02 20:54:50 +0530 |
|---|---|---|
| committer | Aditya Telange <21258296+adityatelange@users.noreply.github.com> | 2021-09-02 20:54:50 +0530 |
| commit | 5bc9c5a73b74578e76314bc0a5acdd3b8ed34fc8 (patch) | |
| tree | dceba126806b61a220da5b8a3ea482f634502b23 | |
| parent | 2aad433ae5912d3dbb6dc680e107a8c8fca36be9 (diff) | |
Allow emabling/disabling responsiveImages per page #518
| -rw-r--r-- | layouts/partials/cover.html | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html index e7e2df4..6c7d1ae 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -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) -}} |
