{{- $source := $.Destination | safeURL -}} {{- $public := print "public/" $source -}} {{- $remote := resources.GetRemote $source -}} {{- $local := "" -}} {{- $width := "" -}} {{- $height := "" -}} {{- $cache := "" -}} {{- $dimensions := "600x360" -}} {{- $immutable := print (.Page.Permalink | relURL | humanize | urlize) "-" ($source | sha256 | truncate 8 "") -}} {{- with $remote -}} {{- with .Err -}} {{- if fileExists $public -}} {{- $local = resources.Get $public -}} {{- with $local -}} {{- $local = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Page.Section "/" (path.Base .)) -}} {{- end -}} {{ $source = print ("" | absURL) $source }} {{- else -}} {{- $404image := resources.Get "data/media/404.png" -}} {{- with $404image -}} {{- $width = .Width -}} {{- $height = .Height -}} {{- end -}} {{ $source = $404image.RelPermalink }} {{- end -}} {{- else -}} {{- $cache = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Page.Section "/" (path.Base .)) -}} {{ end }} {{ end }} {{- /* This comment removes trailing newlines and white spaces. */ -}}
{{- with $local }} {{- $local = .Fit (print $dimensions " webp") }} {{- $local = $local | resources.Copy (print (partial "function-paths-media.html") "/" $.Page.Section "/" $immutable ".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 = .Fit (print $dimensions " webp") }} {{- $cache = $cache | resources.Copy (print $.Page.Section "/media/" $immutable ".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 }} {{- end }} {{ $.Text | htmlUnescape }}
{{ with $.Title -}} {{ . | markdownify }} {{ else -}} Image/Picture {{ end -}}
Index: {{ with $cache }} {{ print "[Cache](" . ")" | markdownify }} · {{ end }} {{ print "[Source](" $source ")" | markdownify }}
{{- /* This comment removes trailing newlines and white spaces. */ -}}