feat: update widget page to get backgrounds from assets/media/ dir

See #2119
This commit is contained in:
George Cushen committed 2021-02-26 00:12:49 +00:00
1 parent 6b9fdd9482
commit 33e92dc8cb
1 file changed
+7 -3
+7 -3
View File
@@ -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") }}