diff options
author | tdro <tdro@noreply.example.com> | 2022-06-05 20:55:24 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-06-05 20:55:24 -0400 |
commit | 7bb81f12d3d9032f182acee84f86c893340e0ead (patch) | |
tree | d94ce4913fb8315860c6449ab1a53264145f186f /themes/default/layouts/_default/_markup/render-image.html | |
parent | b8c5bcbee5592d7fd1e5774da38d835297f8715f (diff) | |
download | canory-7bb81f12d3d9032f182acee84f86c893340e0ead.tar.gz canory-7bb81f12d3d9032f182acee84f86c893340e0ead.tar.bz2 canory-7bb81f12d3d9032f182acee84f86c893340e0ead.zip |
themes/default/layouts/_default/_markup/render-image: Cache remote images to static folder
Let's slowly not pollute the public area.
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-image.html')
-rw-r--r-- | themes/default/layouts/_default/_markup/render-image.html | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index 1b73563..05a5c7d 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -4,7 +4,7 @@ {{- $dimensions := "600x" -}} {{- $width := "" -}} {{- $height := "" -}} -{{- $sourceFit := "" -}} +{{- $cache := "" -}} {{- with $remoteImage -}} {{- with .Err -}} @@ -27,7 +27,8 @@ {{- else -}} {{- $width = .Width -}} {{- $height = .Height -}} - {{- $sourceFit = (.Resize $dimensions).Permalink -}} + {{- $cache = .Content | resources.FromString (print "/data/static/images/" (. | urlize)) -}} + {{- $cache = ($cache.Resize $dimensions).Permalink -}} {{ end }} {{ end }} @@ -35,7 +36,7 @@ <figure> <a href="{{ $source }}"> <img loading="lazy" - src="{{ or $sourceFit $source }}" + src="{{ or $cache $source }}" alt="{{ $.Text | htmlUnescape }}" title="{{ $.Text | htmlUnescape }}" width="{{ $width }}" @@ -49,7 +50,7 @@ Image/Picture {{ end -}} <br> - {{ with $sourceFit }} Cache: {{ print "[Link](" . ")" | markdownify }} · {{ end }} + {{ with $cache }} Cache: {{ print "[Link](" . ")" | markdownify }} · {{ end }} Source: {{ print "[Link](" $source ")" | markdownify }} </figcaption> </figure> |