aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-image.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-image.html')
-rw-r--r--themes/default/layouts/_default/_markup/render-image.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html
new file mode 100644
index 0000000..00f37cf
--- /dev/null
+++ b/themes/default/layouts/_default/_markup/render-image.html
@@ -0,0 +1,45 @@
+{{- $source := $.Destination | safeURL -}}
+{{- $localPath := print "content/" $source -}}
+{{- $remoteImage := resources.GetRemote $source -}}
+{{- $width := "" -}}
+{{- $height := "" -}}
+
+{{- with $remoteImage -}}
+ {{- with .Err -}}
+ {{- if fileExists $localPath -}}
+ {{- $localImage := imageConfig $localPath -}}
+ {{- with $localImage -}}
+ {{- $width = .Width -}}
+ {{- $height = .Height -}}
+ {{- end -}}
+ {{- else -}}
+ {{- $source = print "/images/404.png" -}}
+ {{- $localPath = print "static/" $source -}}
+ {{- $localImage := imageConfig $localPath -}}
+ {{- with $localImage -}}
+ {{- $width = .Width -}}
+ {{- $height = .Height -}}
+ {{- end -}}
+ {{- end -}}
+ {{- else -}}
+ {{- $width = .Width -}}
+ {{- $height = .Height -}}
+ {{ end }}
+{{ end }}
+
+{{- /* This comment removes trailing newlines and white spaces. */ -}}
+<figure>
+ <a href="{{ $source }}">
+ <img loading="lazy"
+ src="{{ $source }}"
+ alt="{{ $.Text | htmlUnescape }}"
+ title="{{ $.Text | htmlUnescape }}"
+ width="{{ $width }}"
+ height="{{ $height }}"
+ />
+ </a>
+{{ if $.Title }}
+ <figcaption>{{ $.Title | markdownify }}</figcaption>
+{{ end -}}
+</figure>
+{{- /* This comment removes trailing newlines and white spaces. */ -}}