aboutsummaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
Diffstat (limited to 'themes')
-rw-r--r--themes/default/layouts/partials/function-caches-images.html25
1 files changed, 24 insertions, 1 deletions
diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html
index c8d094d..9a18f7b 100644
--- a/themes/default/layouts/partials/function-caches-images.html
+++ b/themes/default/layouts/partials/function-caches-images.html
@@ -8,6 +8,8 @@
{{- $type := strings.TrimPrefix "." (path.Ext $copy) -}}
{{- $optimized := print $directory "/" $basename ".webp" -}}
{{- $cached := and (fileExists (print "public/" $copy)) (fileExists (print "public/" $optimized)) -}}
+{{- $local := print "public/" $source -}}
+{{- $localized := fileExists $local -}}
{{- with $404image := resources.Get "data/media/404.png" -}}
{{- $404image = .Content | resources.FromString (print $target (path.Base .)) -}}
@@ -36,7 +38,28 @@
{{- else -}}
{{- with $image := resources.GetRemote $source -}}
{{- with .Err -}}
- {{- warnf "%s" . -}}
+ {{- if $localized -}}
+ {{- $directory := path.Dir $local -}}
+ {{- $basename := path.BaseName $local -}}
+ {{- $type := strings.TrimPrefix "." (path.Ext $local) -}}
+ {{- with $image := resources.Get $local -}}
+ {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
+ {{- $image = $image.Fit (print $dimensions " " $type) -}}
+ {{- $image = $image | resources.Copy $copy -}}
+ {{-
+ $data = slice | append (dict
+ "Width" $image.Width
+ "Height" $image.Height
+ "Permalink" $image.Permalink
+ "RelPermalink" $image.RelPermalink
+ )
+ -}}
+ {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
+ {{- $image = $image.Fit (print $dimensions " " "webp") -}}
+ {{- $image = $image | resources.Copy $optimized -}}
+ {{- $writeToFile := $image.Permalink -}}
+ {{- end -}}
+ {{- end -}}
{{- else -}}
{{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
{{- $image = $image.Fit (print $dimensions " " $type) -}}