aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/function-caches-images.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/function-caches-images.html')
-rw-r--r--themes/default/layouts/partials/function-caches-images.html28
1 files changed, 23 insertions, 5 deletions
diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html
index d21e72a..df5c17f 100644
--- a/themes/default/layouts/partials/function-caches-images.html
+++ b/themes/default/layouts/partials/function-caches-images.html
@@ -9,7 +9,8 @@
{{- $type := strings.TrimPrefix "." (path.Ext $copy) -}}
{{- $optimized := or .OptimizedCopy (print $directory "/" $basename ".webp") -}}
{{- $optimizedType := strings.TrimPrefix "." (path.Ext $optimized) -}}
-{{- $cached := and (fileExists (print "public/" $copy)) (fileExists (print "public/" $optimized)) -}}
+{{- $isFile := ne (path.Base $copy) "." -}}
+{{- $cached := and $isFile (fileExists (print "public/" $copy)) (fileExists (print "public/" $optimized)) -}}
{{- $local := print "public/" $source -}}
{{- $localized := fileExists $local -}}
@@ -28,6 +29,9 @@
{{- 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
@@ -36,6 +40,16 @@
"RelPermalink" $image.RelPermalink
)
-}}
+ {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
+ {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $optimizedType) -}} {{- end -}}
+ {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $optimizedType) -}} {{- end -}}
+ {{- $image = $image | resources.Copy $optimized -}}
+ {{-
+ $data = merge $data (dict
+ "OptPermalink" $image.Permalink
+ "OptRelPermalink" $image.RelPermalink
+ )
+ -}}
{{- end -}}
{{- else -}}
{{- with $image := resources.GetRemote $source -}}
@@ -46,7 +60,8 @@
{{- $type := strings.TrimPrefix "." (path.Ext $local) -}}
{{- with $image := resources.Get $local -}}
{{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
- {{- $image = $image.Fit (print $fit " " $type) -}}
+ {{- 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
@@ -57,7 +72,8 @@
)
-}}
{{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
- {{- $image = $image.Fit (print $fit " " $optimizedType) -}}
+ {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $optimizedType) -}} {{- end -}}
+ {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $optimizedType) -}} {{- end -}}
{{- $image = $image | resources.Copy $optimized -}}
{{-
$data = merge $data (dict
@@ -69,7 +85,8 @@
{{- end -}}
{{- else -}}
{{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
- {{- $image = $image.Fit (print $fit " " $type) -}}
+ {{- 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
@@ -80,7 +97,8 @@
)
-}}
{{- $image = .Content | resources.FromString (print $target (path.Base .)) -}}
- {{- $image = $image.Fit (print $fit " " $optimizedType) -}}
+ {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $optimizedType) -}} {{- end -}}
+ {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $optimizedType) -}} {{- end -}}
{{- $image = $image | resources.Copy $optimized -}}
{{-
$data = merge $data (dict