From 18f1ed9978849315e63bd970eaeab1a401d3a3fb Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Tue, 22 Jul 2025 01:30:39 +0800 Subject: [PATCH] refactor: simplify background image syntax --- layouts/partials/hero/background.html | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index a2c83d7a..9c1eb321 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -36,15 +36,11 @@ {{ end }}
- {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} - {{ with . }} - Background Image - {{ end }} - {{ else }} - {{ with .Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} - Background Image - {{ end }} + {{ $imageURL := .RelPermalink }} + {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} + {{ $imageURL = (.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x")).RelPermalink }} {{ end }} + Background Image