From 1c27c28a4b87e005bd3a1fcf895324760884b863 Mon Sep 17 00:00:00 2001 From: Thedro Neely Date: Tue, 12 Apr 2022 02:32:38 -0400 Subject: generators/hugo/_default/_markup/render-image: Fail with place holder --- .../layouts/_default/_markup/render-image.html | 70 ++++++++++++---------- 1 file 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. */ -}}
- + {{ $.Text }} -
- {{ $.Title | markdownify }} -
+{{ if $.Title }} +
{{ $.Title | markdownify }}
+{{ end -}}
{{- /* This comment removes trailing newlines. */ -}} -- cgit v1.2.3