aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2022-04-12 02:32:38 -0400
committerThedro Neely <thedroneely@gmail.com>2022-04-12 02:32:38 -0400
commit1c27c28a4b87e005bd3a1fcf895324760884b863 (patch)
tree763b8a72f1cb0e6a9a1fa724e3d79b81fbe90025
parent09e53de2d96f2b78144ae408f7206212e8981ac4 (diff)
downloadthedroneely.com-1c27c28a4b87e005bd3a1fcf895324760884b863.tar.gz
thedroneely.com-1c27c28a4b87e005bd3a1fcf895324760884b863.tar.bz2
thedroneely.com-1c27c28a4b87e005bd3a1fcf895324760884b863.zip
generators/hugo/_default/_markup/render-image: Fail with place holder
-rw-r--r--generators/hugo/themes/tdro/layouts/_default/_markup/render-image.html70
1 files changed, 37 insertions, 33 deletions
diff --git a/generators/hugo/themes/tdro/layouts/_default/_markup/render-image.html b/generators/hugo/themes/tdro/layouts/_default/_markup/render-image.html
index 70f0f2f..5307cc2 100644
--- a/generators/hugo/themes/tdro/layouts/_default/_markup/render-image.html
+++ b/generators/hugo/themes/tdro/layouts/_default/_markup/render-image.html
@@ -1,41 +1,45 @@
-{{ $localPath := print "public/" ($.Destination | safeURL) }}
-{{ $remoteImage := resources.GetRemote ($.Destination | safeURL) }}
+{{- $source := $.Destination | safeURL -}}
+{{- $localPath := print "public/" $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/thumbnails/placeholder.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. */ -}}
<figure>
- <a href="{{ $.Destination | safeURL }}" onclick="return false;">
+ <a href="{{ $source }}" onclick="return false;">
<img data-image-zoom
- src="{{ $.Destination | safeURL }}"
- alt="{{ $.Text }}"
- title="{{ $.Text | htmlUnescape | safeHTML }}"
- width="
- {{- with $remoteImage -}}
- {{- with .Err -}}
- {{ $localImage := imageConfig $localPath }}
- {{- with $localImage -}}
- {{ .Width }}
- {{- end -}}
- {{- else -}}
- {{- .Width -}}
- {{- end -}}
- {{- end -}}
- "
- height="
- {{- with $remoteImage -}}
- {{- with .Err -}}
- {{ $localImage := imageConfig $localPath }}
- {{- with $localImage -}}
- {{ .Height }}
- {{- end -}}
- {{- else -}}
- {{ .Height }}
- {{- end -}}
- {{- end -}}
- "
+ src="{{ $source }}"
+ alt="{{ $.Text | htmlUnescape }}"
+ title="{{ $.Text | htmlUnescape }}"
+ width="{{ $width }}"
+ height="{{ $height }}"
/>
</a>
- <figcaption class="has-text-grey-dark">
- {{ $.Title | markdownify }}
- </figcaption>
+{{ if $.Title }}
+<figcaption class="has-text-grey-dark">{{ $.Title | markdownify }}</figcaption>
+{{ end -}}
</figure>
{{- /* This comment removes trailing newlines. */ -}}