From 57796c86497b549ecb0c1017307e07f6db7b0ee6 Mon Sep 17 00:00:00 2001 From: PCloud Date: Sat, 8 Jun 2024 14:29:57 +0100 Subject: [PATCH] fix: inlined image (#1292) * fix: render image as figure only when there is caption * chore: add test case --- .../content/posts/tests/image-tests/index.md | 12 ++++++++++++ .../content/posts/tests/image-tests/pin_black.png | Bin 0 -> 116 bytes .../content/posts/tests/image-tests/pin_red.png | Bin 0 -> 123 bytes .../content/posts/tests/image-tests/pin_white.png | Bin 0 -> 116 bytes layouts/_default/_markup/render-image.html | 14 +++++++++----- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 exampleSite/content/posts/tests/image-tests/index.md create mode 100644 exampleSite/content/posts/tests/image-tests/pin_black.png create mode 100644 exampleSite/content/posts/tests/image-tests/pin_red.png create mode 100644 exampleSite/content/posts/tests/image-tests/pin_white.png diff --git a/exampleSite/content/posts/tests/image-tests/index.md b/exampleSite/content/posts/tests/image-tests/index.md new file mode 100644 index 000000000..2115c85f0 --- /dev/null +++ b/exampleSite/content/posts/tests/image-tests/index.md @@ -0,0 +1,12 @@ +--- +title: "Image Tests" +date: 2024-06-06T12:41:49+01:00 +lastmod: 2024-06-06T12:41:49+01:00 +draft: true +hiddenFromHomePage: true +hiddenFromSearch: true +--- + +- Test 1: ![](./pin_black.png) +- Test 2: ![](./pin_red.png) +- Test 3: ![](./pin_white.png) diff --git a/exampleSite/content/posts/tests/image-tests/pin_black.png b/exampleSite/content/posts/tests/image-tests/pin_black.png new file mode 100644 index 0000000000000000000000000000000000000000..16b625c2e7ed611024467623feafb59289db5daf GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6jbwc zaSW-LlPnN^;g`Sf8H20`|1TQ+v7eRmum9PU|BG7>{}+sqV`6BSr6#}Zmf%^S4hBzG KKbLh*2~7at86l?t literal 0 HcmV?d00001 diff --git a/exampleSite/content/posts/tests/image-tests/pin_red.png b/exampleSite/content/posts/tests/image-tests/pin_red.png new file mode 100644 index 0000000000000000000000000000000000000000..9dbdedf0fe66ab35279177fe3c4464329b9aafae GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6x8)} zaSW-LlU%WC&4>B3W+YxY@PBdQkNJ;MKBq)1Ijr7%uhrk3x5i4U?f=S|ISeHnu`(%d S!eW6M89ZJ6T-G@yGywo0{Uu2N literal 0 HcmV?d00001 diff --git a/exampleSite/content/posts/tests/image-tests/pin_white.png b/exampleSite/content/posts/tests/image-tests/pin_white.png new file mode 100644 index 0000000000000000000000000000000000000000..37142be99c451adc333bf1c0fb8627654fd30a3b GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6jbwc zaSW-LlU(ub&CU9(q_#lj|NU(b|6fe`TyL`ckG!tTzy1TC1Q^cB9Jynow{Znf2ZN`p KpUXO@geCw8t0L+E literal 0 HcmV?d00001 diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 304aab1a3..8f6ec8c30 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -4,11 +4,15 @@ (dict "Process" "resize 1200x webp q75" "descriptor" "1200w") (dict "Process" "resize 1600x webp q75" "descriptor" "1600w") -}} + +{{- if .Title -}}
{{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" $lightgallery "Loading" "lazy" "Sizes" "auto" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}} - {{- if .Title -}} -
- {{- .Title | safeHTML -}} -
- {{- end -}} +
+ {{- .Title | safeHTML -}} +
+{{- else -}} + {{- dict "Src" .Destination "Class" "tw-inline" "Title" .Text "Caption" .Title "Loading" "lazy" "Sizes" "auto" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}} +{{- end -}} +