From e6871f77dad184e570ff920e38f59b23933c6998 Mon Sep 17 00:00:00 2001 From: tdro Date: Thu, 1 Dec 2022 23:38:56 -0500 Subject: themes/default/layouts/partials/function-caches-images: Don't process on cached just return Huh --- .../layouts/partials/function-caches-images.html | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html index c64caf1..4e61760 100644 --- a/themes/default/layouts/partials/function-caches-images.html +++ b/themes/default/layouts/partials/function-caches-images.html @@ -13,9 +13,15 @@ {{- $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 @@ -28,26 +34,19 @@ {{- if $cached -}} {{- with $image := resources.Get (print "public/" $copy) -}} - {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} - {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $type) -}} {{- end -}} - {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $type) -}} {{- end -}} - {{- $image = $image | resources.Copy $copy -}} {{- $data = (dict - "Width" $image.Width - "Height" $image.Height - "Permalink" $image.Permalink - "RelPermalink" $image.RelPermalink + "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) ) -}} - {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} - {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $alternateType) -}} {{- end -}} - {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $alternateType) -}} {{- end -}} - {{- $image = $image | resources.Copy $alternateCopy -}} + {{- $image = resources.Get (print "public/" $alternateCopy) -}} {{- $data = merge $data (dict - "AltPermalink" $image.Permalink - "AltRelPermalink" $image.RelPermalink + "AltPermalink" (strings.Replace $image.Permalink $publicPath $baseURL) + "AltRelPermalink" (strings.Replace $image.RelPermalink $publicPath $baseURL) ) -}} {{- end -}} -- cgit v1.2.3