diff --git a/themes/patek/layouts/shortcodes/blogPhoto.html b/themes/patek/layouts/shortcodes/blogPhoto.html index 23ba285..8b5b361 100644 --- a/themes/patek/layouts/shortcodes/blogPhoto.html +++ b/themes/patek/layouts/shortcodes/blogPhoto.html @@ -24,7 +24,7 @@ or {{- if (eq $img nil) }}{{ errorf "Image %s not found in %s" $imageName .Position }}{{ end -}} {{- $sizes := slice (slice 640 360 50) (slice 1280 720 50) (slice 1920 1080 50) -}} {{- $srcset := slice -}} -{{- $largest := index $sizes 0 -}} +{{- $largest := false -}} {{- range $sizes -}} {{- if (or (gt $img.Width (index . 0)) (gt $img.Height (index . 1))) -}} {{- $resized := $img.Fit (printf "%dx%d q%d" (index . 0) (index . 1) (index . 2)) -}} @@ -33,4 +33,10 @@ or {{- end -}} {{- end -}} +{{- if (lt (len $srcset) (len $sizes)) -}} + {{- $compressed := $img.Fit (printf "%dx%d q50" $img.Width $img.Height) -}} + {{- $srcset = $srcset | append (printf "%s %dw" $compressed.RelPermalink $compressed.Width) -}} + {{- $largest = $compressed -}} +{{- end -}} + {{ $alt }}