From 7108eefac11bda75a0859bd428fd147476f390a4 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Wed, 29 Jul 2020 20:24:17 +0100 Subject: [PATCH] fix: make media library dir configurable Fixes shortcode scratch context Fix d9ff93a1c27575c64eef80fe4a40f6d022877cac --- 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 232d76e5..2b5fbaa5 100644 --- a/layouts/shortcodes/audio.html +++ b/layouts/shortcodes/audio.html @@ -3,7 +3,7 @@ {{ $path := "" }} {{ $root_dir := "" }} -{{ $media_dir := $.Scratch.Get "media_dir" }} +{{ $media_dir := .Page.Scratch.Get "media_dir" }} {{ if .Get "library" }} {{ $path = printf "%s/" $media_dir }} {{ $root_dir = "static/" }} diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 6e819549..ef71ff9d 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 := $.Scratch.Get "media_dir" }} +{{ $media_dir := .Page.Scratch.Get "media_dir" }} {{ $asset := (.Page.Resources.ByType "image").GetMatch (.Get "src") }} {{ $image_src := (.Get "src") }} {{ if $asset }} diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html index 37a61502..01b6a91b 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 := $.Scratch.Get "media_dir" }} + {{ $media_dir := .Page.Scratch.Get "media_dir" }} {{ $.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 e34edc7f..579e9b01 100644 --- a/layouts/shortcodes/video.html +++ b/layouts/shortcodes/video.html @@ -2,7 +2,7 @@ {{ $path := "" }} {{ $root_dir := "" }} -{{ $media_dir := $.Scratch.Get "media_dir" }} +{{ $media_dir := .Page.Scratch.Get "media_dir" }} {{ if .Get "library" }} {{ $path = printf "%s/" $media_dir }} {{ $root_dir = "static/" }}