aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-image.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-06-24 03:36:33 -0400
committertdro <tdro@noreply.example.com>2022-06-24 03:36:33 -0400
commitd8835677c49292d9186003df777ece0670ba742e (patch)
tree340cc61d2cddf0c349e970cfa68ed6b7fd0948b3 /themes/default/layouts/_default/_markup/render-image.html
parentf140c37f83753d620bdf3499843e3d11ca4a131d (diff)
downloadcanory-d8835677c49292d9186003df777ece0670ba742e.tar.gz
canory-d8835677c49292d9186003df777ece0670ba742e.tar.bz2
canory-d8835677c49292d9186003df777ece0670ba742e.zip
themes/default: static/images -> data/media
Add media path. Translate static images to data media.
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-image.html')
-rw-r--r--themes/default/layouts/_default/_markup/render-image.html43
1 files changed, 24 insertions, 19 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html
index 3c027a9..8f03de5 100644
--- a/themes/default/layouts/_default/_markup/render-image.html
+++ b/themes/default/layouts/_default/_markup/render-image.html
@@ -1,31 +1,31 @@
-{{- $source := $.Destination | safeURL -}}
-{{- $public := print "public/" $source -}}
-{{- $remote := resources.GetRemote $source -}}
-{{- $local := "" -}}
-{{- $width := "" -}}
-{{- $height := "" -}}
-{{- $cache := "" -}}
-{{- $dimensions := "600x360" -}}
+{{- $source := $.Destination | safeURL -}}
+{{- $public := print "public/" $source -}}
+{{- $remote := resources.GetRemote $source -}}
+{{- $local := "" -}}
+{{- $width := "" -}}
+{{- $height := "" -}}
+{{- $cache := "" -}}
+{{- $dimensions := "600x360" -}}
+{{- $immutable := print (.Page.Permalink | humanize | urlize) "-" ($source | sha256 | truncate 8 "") -}}
{{- with $remote -}}
{{- with .Err -}}
{{- if fileExists $public -}}
{{- $local = resources.Get $public -}}
{{- with $local -}}
- {{- $local = .Content | resources.FromString (print "/data/static/images/" (. | urlize)) }}
+ {{- $local = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Page.Section "/" (path.Base .)) -}}
{{- end -}}
{{ $source = print ("" | absURL) $source }}
{{- else -}}
- {{- $404origin := print "/images/404.png" -}}
- {{- $404image := imageConfig (print "static/" $404origin) -}}
+ {{- $404image := resources.Get "data/media/404.png" -}}
{{- with $404image -}}
{{- $width = .Width -}}
{{- $height = .Height -}}
{{- end -}}
- {{ $source = print ("" | absURL) $404origin }}
+ {{ $source = $404image.RelPermalink }}
{{- end -}}
{{- else -}}
- {{- $cache = .Content | resources.FromString (print $.Page.Section "/media/" (. | urlize)) -}}
+ {{- $cache = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Page.Section "/" (path.Base .)) -}}
{{ end }}
{{ end }}
{{- /* This comment removes trailing newlines and white spaces. */ -}}
@@ -33,16 +33,21 @@
<a href="{{ $source }}">
<picture>
{{- with $local }}
- <source srcset="{{- ($local.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" />
- {{- $local = $local.Fit $dimensions }}
+ {{- $local = .Fit (print $dimensions " webp") }}
+ {{- $local = $local | resources.Copy (print (partial "function-paths-media.html") "/" $.Page.Section "/" $immutable ".webp") }}
+ <source srcset="{{- $local.RelPermalink -}}" type="image/webp" />
+ {{- $local = .Fit $dimensions }}
+ {{- $local = $local | resources.Copy (print (partial "function-paths-media.html") "/" $.Page.Section "/" $immutable (path.Ext $local)) }}
{{- $width = $local.Width -}}
{{- $height = $local.Height -}}
+ {{- $writeToFile := $local.Permalink }}
{{- end }}
{{- with $cache }}
- {{- $cache = .Content | resources.FromString (print "/data/static/images/" (. | urlize)) }}
- <source srcset="{{- ($cache.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" />
- {{- $cache = .Content | resources.FromString (. | urlize) -}}
- {{- $cache = $cache.Fit $dimensions }}
+ {{- $cache = .Fit (print $dimensions " webp") }}
+ {{- $cache = $cache | resources.Copy (print $.Page.Section "/media/" $immutable ".webp") }}
+ <source srcset="{{- $cache.RelPermalink -}}" type="image/webp" />
+ {{- $cache = .Fit $dimensions }}
+ {{- $cache = $cache | resources.Copy (print (partial "function-paths-media.html") "/" $.Page.Section "/" $immutable (path.Ext $cache)) }}
{{- $width = $cache.Width -}}
{{- $height = $cache.Height -}}
{{- $cache = $cache.RelPermalink }}