From e591d16e9d1209cea41428419da164f435c194e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Tue, 21 Apr 2020 22:55:57 +0200 Subject: [PATCH 1/2] Use
and
in blogPhoto shortcode --- themes/patek/layouts/shortcodes/blogPhoto.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/themes/patek/layouts/shortcodes/blogPhoto.html b/themes/patek/layouts/shortcodes/blogPhoto.html index 8b5b361..786f00d 100644 --- a/themes/patek/layouts/shortcodes/blogPhoto.html +++ b/themes/patek/layouts/shortcodes/blogPhoto.html @@ -5,7 +5,12 @@ Usage: or -{{< blogPhoto src="filename_relative_to_page.ext" alt="Alt text" >}} +{{< blogPhoto src="filename_relative_to_page.ext" alt="Alt text" … >}} + +where possible named params are: +* src - path to the image in page bundle +* alt - textual description of the image, the alt attribute +* caption (optional) - the caption displayed under the image, defaults to `alt`. Set to false to disable caption rendering */ -}} {{- $imageName := false -}} @@ -19,6 +24,7 @@ or {{- end -}} {{- if (eq $imageName nil) }}{{ errorf "Missing image name in %s" .Position }}{{ end -}} {{- if (eq $alt nil) }}{{ errorf "Missing alt for image %s in %s" $imageName .Position }}{{ end -}} +{{- $caption := cond (eq (.Get "caption") false) false (default $alt (.Get "caption")) -}} {{- $img := .Page.Resources.GetMatch $imageName | default nil -}} {{- if (eq $img nil) }}{{ errorf "Image %s not found in %s" $imageName .Position }}{{ end -}} @@ -39,4 +45,7 @@ or {{- $largest = $compressed -}} {{- end -}} -{{ $alt }} +
+ {{ $alt }} + {{ if (ne $caption false) }}
{{ $caption }}
{{ end }} +
From 5be48c59c6062c10ca1949fcc610362db159aceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Sun, 3 May 2020 14:47:11 +0200 Subject: [PATCH 2/2] Raise the quality of low res images They might be scaled up by the browser making compression artifacts much more visible. --- themes/patek/layouts/shortcodes/blogPhoto.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/patek/layouts/shortcodes/blogPhoto.html b/themes/patek/layouts/shortcodes/blogPhoto.html index 786f00d..ccd3a23 100644 --- a/themes/patek/layouts/shortcodes/blogPhoto.html +++ b/themes/patek/layouts/shortcodes/blogPhoto.html @@ -40,7 +40,7 @@ where possible named params are: {{- end -}} {{- if (lt (len $srcset) (len $sizes)) -}} - {{- $compressed := $img.Fit (printf "%dx%d q50" $img.Width $img.Height) -}} + {{- $compressed := $img.Fit (printf "%dx%d q90" $img.Width $img.Height) -}} {{- $srcset = $srcset | append (printf "%s %dw" $compressed.RelPermalink $compressed.Width) -}} {{- $largest = $compressed -}} {{- end -}}