diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e9e862..d35dc5cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ All notable changes to this project will be documented in this file. - :sparkles: Feat: update echarts theme config - :zap: Perf: remove extra spaces in plugin link - :wheelchair: Feat(accessibility): use `aria-hidden=true` on icons that AT should ignore -- :bug: Fix: add function doc2unix to unify new lines symbol between Windows and Unix/Mac OS +- :recycle: Refactor: image rendering +- :bug: Fix: add function `dos2unix` to unify new lines symbol between Windows and Unix/Mac OS - :bug: Fix: author display error in post and markdown file - :bug: Fix: use data attributes or class replace for custom attributes - :bug: Fix: attribute `media` not allowed on element meta in `[name=theme-color]` diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 748da74a..579a360b 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,10 +1,10 @@ {{- if .Title -}}
- {{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" true "Resources" .Page.Resources | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Resources" .Page.Resources | partial "plugin/image.html" -}}
- {{- .Title | safeHTML -}} + {{- .Text | safeHTML -}}
{{- else -}} - {{- dict "Src" .Destination "Title" .Text "Resources" .Page.Resources | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Alt" .Text "Resources" .Page.Resources | partial "plugin/image.html" -}} {{- end -}} diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 0f4f7a45..4a0aab45 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -19,16 +19,21 @@ {{- end -}} {{- $alt := .Alt | default $src -}} +{{- $caption := .Caption | default $alt -}} {{- $loading := resources.Get "svg/loading.svg" | minify -}} {{- if .Linked -}} - + {{ $alt }} + alt="{{ $alt }}" + title="{{ .Title | default $alt }}" + {{- with .Height }} height="{{ . }}"{{- end -}} + {{- with .Width }} width="{{ . }}"{{- end -}} + /> {{- else -}} {{ $alt }} + {{- with $width }} width="{{ . }}"{{- end -}} + {{- with $height }} height="{{ . }}"{{- end -}} + /> {{- end -}}