diff options
| author | Aditya Telange <21258296+adityatelange@users.noreply.github.com> | 2020-10-23 11:35:30 +0530 |
|---|---|---|
| committer | Aditya Telange <21258296+adityatelange@users.noreply.github.com> | 2020-10-23 11:35:30 +0530 |
| commit | 834feb9adc209c3151a229fe5b7d521400153f51 (patch) | |
| tree | 23af3d56c4abfbc2629b29640e7215467e6caa43 | |
| parent | 51c58ad0d570f4a7f2e460da524b01b9a5710473 (diff) | |
cover: responsive cover: generate responsive images only in "production" env
- will reduce render time in development env
| -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 7be43ea..b448732 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -8,7 +8,8 @@ {{- if $addLink }}<a href="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" target="_blank">{{ end -}} {{- $sizes := (slice "360" "480" "720" "1080" "1500") }} {{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") }} - {{- if (and (in $processableFormats $cover.MediaType.SubType) (ne .Site.Params.cover.responsiveImages false)) }} + {{- $prod := (eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production")) }} + {{- if (and (in $processableFormats $cover.MediaType.SubType) (ne .Site.Params.cover.responsiveImages false) (eq $prod true)) }} <img srcset="{{- range $size := $sizes -}} {{- if (ge $cover.Width $size) -}} {{ printf "%s %s" (($cover.Resize (printf "%sx q100" $size)).Permalink) (printf "%sw ," $size) -}} |
