feat: convert card images to webp format

This commit is contained in:
Henk Verlinde 2022-06-28 12:51:02 +02:00
parent 77d0890ba4
commit d92f8eb79e
2 changed files with 12 additions and 4 deletions

View File

@ -39,7 +39,7 @@
{{ range . -}}
<div class="col">
<div class="card">
{{- .Scratch.Set "fillImage" "1270x620 Center" -}}
{{- .Scratch.Set "fillImageCard" "1270x620 Center" -}}
{{ partial "content/card-image.html" . }}
<div class="card-body">
<article>

View File

@ -1,4 +1,4 @@
{{ $fillImage := .Scratch.Get "fillImage" }}
{{ $fillImage := .Scratch.Get "fillImageCard" }}
{{ if not $fillImage -}}
{{ $fillImage = site.Params.fillImage }}
{{ end -}}
@ -8,7 +8,15 @@
{{ $image = resources.Get (printf "%s%s" "images/" site.Params.defaultImage) }}
{{ end -}}
{{ $image = $image.Fill $fillImage }}
{{ $webp := printf "%s%s" $fillImage " webp" }}
{{ $image = $image.Resize $webp}}
{{ $lqip := $image.Resize site.Params.lqipWidth -}}
<img class="card-img-top img-fluid lazyload blur-up" src="{{ $lqip.Permalink }}" data-src="{{ $image.Permalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}">
<img
class="card-img-top img-fluid lazyload blur-up"
src="{{ $lqip.Permalink }}"
data-src="{{ $image.Permalink }}"
width="{{ $image.Width }}"
height="{{ $image.Height }}"
alt="{{ .Title }}">