From d36a7c0950e0607881545e6ff171dcdff127e420 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sat, 22 Aug 2020 21:02:30 +0200 Subject: [PATCH] fix(markdown image): be able to insert external images --- layouts/_default/_markup/render-image.html | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 1502c0e..dc57481 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,18 +1,22 @@ {{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}} -{{- $small := $image.Resize "480x" -}} -{{- $big := $image.Resize "1024x" -}} -{{- $alt := .PlainText | safeHTML -}} -{{- $caption := "" -}} -{{- with $alt -}} -{{- $caption = . | safeHTML -}} -{{- end -}} -
- - {{ if $alt }}{{ $alt }}{{ else if $caption }}{{ $caption | markdownify | plainify }}{{ else }} {{ end }} - - {{ with $caption }} -
{{ . | markdownify }}
- {{ end }} -
\ No newline at end of file +{{- if $image -}} + {{- $small := $image.Resize "480x" -}} + {{- $big := $image.Resize "1024x" -}} + {{- $alt := .PlainText | safeHTML -}} + {{- $caption := "" -}} + {{- with $alt -}} + {{- $caption = . | safeHTML -}} + {{- end -}} +
+ + {{ if $alt }}{{ $alt }}{{ else if $caption }}{{ $caption | markdownify | plainify }}{{ else }} {{ end }} + + {{ with $caption }} +
{{ . | markdownify }}
+ {{ end }} +
+{{- else -}} + {{ .Text }} +{{- end -}} \ No newline at end of file