From c0f0326de7e4fb3f3d5e6f59d930870933672659 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 24 Aug 2020 13:21:29 +0100 Subject: [PATCH] fix: $media_dir edge case for shortcode instance within widget --- layouts/shortcodes/audio.html | 2 +- layouts/shortcodes/figure.html | 2 +- layouts/shortcodes/gallery.html | 2 +- layouts/shortcodes/video.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/layouts/shortcodes/audio.html b/layouts/shortcodes/audio.html index 2b5fbaa5..322e976b 100644 --- a/layouts/shortcodes/audio.html +++ b/layouts/shortcodes/audio.html @@ -3,7 +3,7 @@ {{ $path := "" }} {{ $root_dir := "" }} -{{ $media_dir := .Page.Scratch.Get "media_dir" }} +{{ $media_dir := site.Params.media_dir | default "media" }} {{ if .Get "library" }} {{ $path = printf "%s/" $media_dir }} {{ $root_dir = "static/" }} diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index ba746af3..718f0b95 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -1,6 +1,6 @@ {{/* Enable image to be loaded from local page dir or media library at `static/media/`. */}} -{{ $media_dir := .Page.Scratch.Get "media_dir" }} +{{ $media_dir := site.Params.media_dir | default "media" }} {{ $asset := (.Page.Resources.ByType "image").GetMatch (.Get "src") }} {{ $is_svg := false }} {{ if $asset }} diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html index 01b6a91b..2b5dd508 100644 --- a/layouts/shortcodes/gallery.html +++ b/layouts/shortcodes/gallery.html @@ -42,7 +42,7 @@ {{ $.Scratch.Set "src" .image }} {{ if gt (len .image) 4 }} {{ if ne "http" (slicestr .image 0 4) }} - {{ $media_dir := .Page.Scratch.Get "media_dir" }} + {{ $media_dir := site.Params.media_dir | default "media" }} {{ $.Scratch.Set "src" (printf "%s/%s" $media_dir .image | relURL) }} {{ end }} {{ end }} diff --git a/layouts/shortcodes/video.html b/layouts/shortcodes/video.html index 579e9b01..ceafb7d1 100644 --- a/layouts/shortcodes/video.html +++ b/layouts/shortcodes/video.html @@ -2,7 +2,7 @@ {{ $path := "" }} {{ $root_dir := "" }} -{{ $media_dir := .Page.Scratch.Get "media_dir" }} +{{ $media_dir := site.Params.media_dir | default "media" }} {{ if .Get "library" }} {{ $path = printf "%s/" $media_dir }} {{ $root_dir = "static/" }}