From 8bfa3fc8bf641989298870fe71a6f01874f36ce8 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Thu, 31 Oct 2024 08:06:05 -0700 Subject: [PATCH] Add support for embedding videos in the figures/image shortcode --- layouts/shortcodes/figures/image.html | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/layouts/shortcodes/figures/image.html b/layouts/shortcodes/figures/image.html index ecf42c9..9372b06 100644 --- a/layouts/shortcodes/figures/image.html +++ b/layouts/shortcodes/figures/image.html @@ -17,31 +17,35 @@ {{ errorf "No images found for name(s) parameter" }} {{- end -}} -
-
- {{ range $img := $imgs }} - {{- $linkedImg := $img -}} - {{- if not $img }} - {{ errorf "Found nil in images list for %s" $.Page.Permalink }} - {{ end -}} +{{ with $item := index $imgs 0 }} +
+
+ {{ if eq $item.ResourceType "image" }} + {{- $processedImage := $item -}} + {{- if $shouldResize -}} + {{ $processedImage = $item.Fit "1280x1280" }} + {{- end -}} - {{- if $shouldResize -}} - {{ $linkedImg = $img.Fit "1280x1280" }} + {{- $altText := $item.Params.alt | default $item.Title -}} + + {{ . }} + + {{ else if eq $item.ResourceType "video" }} + + {{- end }} +
+ {{ if $shouldShowTitle -}} + {{- with $item -}} + {{- if gt (len .Title) 0 -}} +
{{ .Title | markdownify }}
+ {{- end -}} {{- end -}} - - {{- $altText := $img.Params.alt | default $img.Title -}} - - {{ . }} - {{- end }} -
- {{ if $shouldShowTitle -}} - {{- range $imgs -}} - {{- if gt (len .Title) 0 -}} -
{{ .Title }}
- {{- end -}} - {{- end -}} - {{- end }} -
+ +{{ else }} + {{ errorf "Found nil in items list for %s" $.Page.Permalink }} +{{ end }}