aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/canory/messages/xkcd.md3
-rw-r--r--themes/default/layouts/_default/_markup/render-image.html25
2 files changed, 19 insertions, 9 deletions
diff --git a/content/canory/messages/xkcd.md b/content/canory/messages/xkcd.md
index 41ed4a6..fd3ad6a 100644
--- a/content/canory/messages/xkcd.md
+++ b/content/canory/messages/xkcd.md
@@ -7,7 +7,8 @@ author = "canory"
Hosting and linking content is copyright radioactive. Be a good netizen and
avoid hotlinking,
-[but do it when it's acceptable](https://xkcd.com/license.html).
+[but do it when it's acceptable](https://xkcd.com/license.html) (it's cached
+anyway).
![Debugging](https://imgs.xkcd.com/comics/debugging.png "
xkcd: [Debugging](https://xkcd.com/1722)"
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html
index fd83d75..5dcfa80 100644
--- a/themes/default/layouts/_default/_markup/render-image.html
+++ b/themes/default/layouts/_default/_markup/render-image.html
@@ -1,22 +1,23 @@
{{- $source := $.Destination | safeURL -}}
{{- $local := print "content/" $source -}}
{{- $remoteImage := resources.GetRemote $source -}}
+{{- $dimensions := "600x" -}}
{{- $width := "" -}}
{{- $height := "" -}}
+{{- $sourceFit := "" -}}
{{- with $remoteImage -}}
{{- with .Err -}}
{{- if fileExists $local -}}
- {{- $404image := imageConfig $local -}}
- {{- with $404image -}}
+ {{- $localImage := imageConfig $local -}}
+ {{- with $localImage -}}
{{- $width = .Width -}}
{{- $height = .Height -}}
{{- end -}}
{{ $source = print ("" | absURL) $source }}
{{- else -}}
{{- $source = print "/images/404.png" -}}
- {{- $local = print "static/" $source -}}
- {{- $404image := imageConfig $local -}}
+ {{- $404image := imageConfig (print "static/" $source) -}}
{{- with $404image -}}
{{- $width = .Width -}}
{{- $height = .Height -}}
@@ -26,6 +27,7 @@
{{- else -}}
{{- $width = .Width -}}
{{- $height = .Height -}}
+ {{- $sourceFit = (.Resize $dimensions).Permalink -}}
{{ end }}
{{ end }}
@@ -33,15 +35,22 @@
<figure>
<a href="{{ $source }}">
<img loading="lazy"
- src="{{ $source }}"
+ src="{{ or $sourceFit $source }}"
alt="{{ $.Text | htmlUnescape }}"
title="{{ $.Text | htmlUnescape }}"
width="{{ $width }}"
height="{{ $height }}"
/>
</a>
-{{ if $.Title }}
- <figcaption>{{ $.Title | markdownify }}</figcaption>
-{{ end -}}
+ <figcaption>
+ {{ with $.Title -}}
+ {{ . | markdownify }}
+ {{ else -}}
+ Image/Picture
+ {{ end -}}
+ <br>
+ {{ with $sourceFit }} Cache: {{ print "[Link](" . ")" | markdownify }} &middot; {{ end }}
+ Source: {{ print "[Link](" $source ")" | markdownify }}
+ </figcaption>
</figure>
{{- /* This comment removes trailing newlines and white spaces. */ -}}