diff options
author | tdro <tdro@noreply.example.com> | 2022-08-28 00:08:03 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-08-28 00:08:03 -0400 |
commit | 5c08d7666c3b4f75207822344edb7f54e1c4b0cb (patch) | |
tree | cd180a073bc1988cfb99f7982e74a4d833164e31 /themes/default/layouts/partials/function-caches-images.html | |
parent | b77c159ae5cfc45e7fd80457e840e769fc97b555 (diff) | |
download | canory-5c08d7666c3b4f75207822344edb7f54e1c4b0cb.tar.gz canory-5c08d7666c3b4f75207822344edb7f54e1c4b0cb.tar.bz2 canory-5c08d7666c3b4f75207822344edb7f54e1c4b0cb.zip |
themes/default/layouts/partials/function-caches-images: Merge alternate copy properties
Compensate for fit and resize. Set images from user profile configuration.
Diffstat (limited to 'themes/default/layouts/partials/function-caches-images.html')
-rw-r--r-- | themes/default/layouts/partials/function-caches-images.html | 28 |
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 |