From 5518053a2642540add8aa9af5965d50e58149ba2 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Thu, 7 Nov 2024 11:15:10 +0800 Subject: [PATCH] :bug: Fix: image rendering not support base64 syntax (#540) Close #540 --- layouts/_default/_markup/render-image.html | 1 + layouts/partials/init/index.html | 2 +- layouts/partials/plugin/image.html | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 3c3b5fef..2937c655 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,3 +1,4 @@ +{{- /* TODO refactor */ -}} {{- $params := .Page.Params | merge site.Params.page -}} {{- if .Title | and .Text -}} {{- $linked := ne $params.lightgallery false -}} diff --git a/layouts/partials/init/index.html b/layouts/partials/init/index.html index 5d1268ca..7f0c9ec8 100644 --- a/layouts/partials/init/index.html +++ b/layouts/partials/init/index.html @@ -1,4 +1,4 @@ -{{- .Scratch.Set "version" "v0.3.15-3ead0107" -}} +{{- .Scratch.Set "version" "v0.3.15-2a0821f5" -}} {{- .Scratch.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index d128a13c..c3e4f3dd 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -7,6 +7,11 @@ {{- $onerror := "" -}} {{- $cacheRemoteImages := $params.cacheRemoteImages -}} {{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" -}} +{{- $responsive := .Responsive -}} + +{{- if hasPrefix .Src "data:image" -}} + {{- $responsive = false -}} +{{- end -}} {{- /* handle for default size image */ -}} {{- $src := .Src -}} @@ -17,7 +22,7 @@ {{- $src = .RelPermalink -}} {{- end -}} {{- /* only available for image resources that are raster images */ -}} - {{- if (eq .ResourceType "image") | and $suffixValid | and $.Responsive -}} + {{- if (eq .ResourceType "image") | and $suffixValid | and $responsive -}} {{- $style = printf "--width: %vpx;--aspect-ratio: %v / %v;" .Width .Width .Height | safeHTMLAttr -}} {{- end -}} {{- end -}} @@ -26,7 +31,7 @@ {{- $srcMedium := $src -}} {{- $srcLarge := .SrcLarge | default $src -}} -{{- if .Responsive }} +{{- if $responsive }} {{- /* handle for small size image */ -}} {{- $suffixValidSmall := dict "Path" $srcSmall "Suffixes" $suffixList | partial "function/suffix-validation.html" -}} {{- with dict "Path" .SrcSmall "Resources" .Resources "CacheRemoteImages" $cacheRemoteImages.enable | partial "function/resource.html" -}} @@ -89,7 +94,7 @@ {{- end -}}