aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-12-01 23:38:56 -0500
committertdro <tdro@noreply.example.com>2022-12-01 23:38:56 -0500
commite6871f77dad184e570ff920e38f59b23933c6998 (patch)
tree330a6ab613c81f9d4db0cb54b6da53c0164ff519
parent6d2b8e0fc85be29f5a8cdbaa27253b5df68cd796 (diff)
downloadcanory-e6871f77dad184e570ff920e38f59b23933c6998.tar.gz
canory-e6871f77dad184e570ff920e38f59b23933c6998.tar.bz2
canory-e6871f77dad184e570ff920e38f59b23933c6998.zip
themes/default/layouts/partials/function-caches-images: Don't process on cached just return
Huh
-rw-r--r--themes/default/layouts/partials/function-caches-images.html29
1 files 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 -}}