From 05956b83b813e9ab3beebe0802f4ebe7a21c77fe Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 31 Dec 2024 09:37:19 -0800 Subject: [PATCH] Make some improvements to the fullwidth-image partial - Add some handling of SVGs so the template doesn't attempt to resize them. - Include custom classes in the
attribute - Do not link to SVG images - Only include if there are multiple sized images. This mostly supports SVG figures where there's only ever one. --- .../page/figures/fullwidth-image.html | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/layouts/partials/page/figures/fullwidth-image.html b/layouts/partials/page/figures/fullwidth-image.html index ed39f0e..74b29e3 100644 --- a/layouts/partials/page/figures/fullwidth-image.html +++ b/layouts/partials/page/figures/fullwidth-image.html @@ -1,28 +1,39 @@ {{- $image := .resource -}} -{{- - $resizedImages := dict - "full" ($image.Fit "2560x2560") - "half" ($image.Fit "1280x1280") - "quarter" ($image.Fit "640x640") --}} +{{- $isSVG := strings.Contains $image.MediaType.SubType "svg" -}} +{{- $linksToFullSizeImage := and .linksToFullSizeImage (not $isSVG) -}} + +{{- $resizedImages := dict "full" $image -}} +{{- if not $isSVG -}} + {{- + $resizedImages := dict + "full" ($image.Fit "2560x2560") + "half" ($image.Fit "1280x1280") + "quarter" ($image.Fit "640x640") + -}} +{{ end }} {{- $classes := slice "figure" "figure--image" -}} {{- if eq .size "main" -}} {{ $classes = $classes | append "figure--main-column" }} {{- end -}} +{{- with .class -}} + {{ $classes = $classes | append . }} +{{- end -}}
- {{ if .linksToFullSizeImage -}} + {{ if $linksToFullSizeImage -}} {{- end -}} {{ . }} {{ if .linksToFullSizeImage -}}