From 33e92dc8cb16c5b33f3fb1eced20a95575d3f4a6 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Fri, 26 Feb 2021 00:12:49 +0000 Subject: [PATCH] feat: update widget page to get backgrounds from assets/media/ dir See #2119 --- wowchemy/layouts/partials/widget_page.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wowchemy/layouts/partials/widget_page.html b/wowchemy/layouts/partials/widget_page.html index 62a0ad8f..75159efe 100644 --- a/wowchemy/layouts/partials/widget_page.html +++ b/wowchemy/layouts/partials/widget_page.html @@ -41,9 +41,13 @@ {{ end }} {{ if $bg.image }} - {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}} - {{ $media_dir := $.Scratch.Get "media_dir" }} - {{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg (printf "%s/%s" $media_dir $bg.image | absURL) }} + {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}# + {{ $bg_img := resources.Get (printf "media/%s" $bg.image) }} + {{ if $bg_img }} + {{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg .Permalink }} + {{ else }} + {{ errorf "Couldn't find `%s` in the `assets/media/` folder - please add it." $bg.image }} + {{ end }} {{ with $bg.image_size }} {{/* Allow sizes: actual, cover, and contain. */}} {{ $style_bg = printf "%sbackground-size: %s;" $style_bg (replace . "actual" "auto") }}