From c1a0a33c40b08eb13e412a95cdcdfd869eb3bf2d Mon Sep 17 00:00:00 2001 From: tdro Date: Fri, 2 Dec 2022 00:14:29 -0500 Subject: themes/default/layouts/partials/function-caches-images: Avoid public path split Always ensure image target path --- .../layouts/partials/function-caches-images.html | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html index 4e61760..2102bef 100644 --- a/themes/default/layouts/partials/function-caches-images.html +++ b/themes/default/layouts/partials/function-caches-images.html @@ -13,15 +13,9 @@ {{- $cached := and $isFile (fileExists (print "public/" $copy)) (fileExists (print "public/" $alternateCopy)) -}} {{- $local := print "public/" $source -}} {{- $localized := fileExists $local -}} -{{- $baseURL := "" -}} - -{{- if $baseURL -}} - {{- $baseURL = .Site.BaseURL -}} -{{- end -}} - -{{- $publicPath := print $baseURL "/public" -}} {{- with $404image := resources.Get "data/media/404.png" -}} + {{- $404image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- $data = (dict "Width" $404image.Width @@ -34,19 +28,21 @@ {{- if $cached -}} {{- with $image := resources.Get (print "public/" $copy) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- $data = (dict - "Width" (strings.Replace $image.Width $publicPath $baseURL) - "Height" (strings.Replace $image.Height $publicPath $baseURL) - "Permalink" (strings.Replace $image.Permalink $publicPath $baseURL) - "RelPermalink" (strings.Replace $image.RelPermalink $publicPath $baseURL) + "Width" $image.Width + "Height" $image.Height + "Permalink" $image.Permalink + "RelPermalink" $image.RelPermalink ) -}} {{- $image = resources.Get (print "public/" $alternateCopy) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base $image)) -}} {{- $data = merge $data (dict - "AltPermalink" (strings.Replace $image.Permalink $publicPath $baseURL) - "AltRelPermalink" (strings.Replace $image.RelPermalink $publicPath $baseURL) + "AltPermalink" $image.Permalink + "AltRelPermalink" $image.RelPermalink ) -}} {{- end -}} -- cgit v1.2.3