Skip to content

Commit

Permalink
fix: inlined image (HEIGE-PCloud#1292)
Browse files Browse the repository at this point in the history
* fix: render image as figure only when there is caption

* chore: add test case
  • Loading branch information
HEIGE-PCloud authored and hodory committed Dec 16, 2024
1 parent 64ef512 commit 57796c8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
12 changes: 12 additions & 0 deletions exampleSite/content/posts/tests/image-tests/index.md
Original file line number Diff line number Diff line change
@@ -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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
(dict "Process" "resize 1200x webp q75" "descriptor" "1200w")
(dict "Process" "resize 1600x webp q75" "descriptor" "1600w")
-}}

{{- if .Title -}}
<figure>
{{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" $lightgallery "Loading" "lazy" "Sizes" "auto" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}}
{{- if .Title -}}
<figcaption class="image-caption">
{{- .Title | safeHTML -}}
</figcaption>
{{- end -}}
<figcaption class="image-caption">
{{- .Title | safeHTML -}}
</figcaption>
</figure>
{{- 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 -}}

0 comments on commit 57796c8

Please sign in to comment.