From 767df64ef1817eb789791318e232fc888778ef36 Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Fri, 15 Mar 2024 10:04:41 +0800 Subject: [PATCH] fix: do not apply imageConfig on avif and jxl images (#48) --- layouts/partials/images/image.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/layouts/partials/images/image.html b/layouts/partials/images/image.html index 580e761..6f78fb0 100644 --- a/layouts/partials/images/image.html +++ b/layouts/partials/images/image.html @@ -22,6 +22,7 @@ {{- $page := default page .Page }} {{- $url := urls.Parse $filename }} {{- $params := $url.Query }} +{{- $ext := path.Ext $url.Path }} {{/* Initialize image properties. */}} {{- $src := "" }} {{- $style := default slice .Style }} @@ -159,9 +160,11 @@ {{- if fileExists $filepath }} {{/* Process static image. */}} {{- $src = absURL $url.Path }} - {{- with imageConfig $filepath }} - {{- $naturalHeight = .Height }} - {{- $naturalWidth = .Width }} + {{- if not (in (slice ".avif" ".jxl") $ext) }} + {{- with imageConfig $filepath }} + {{- $naturalHeight = .Height }} + {{- $naturalWidth = .Width }} + {{- end }} {{- end }} {{/* hash by the date. */}} {{- $hash := "" }}