Files
hugo-theme-stack/layouts/_markup/render-image.html
T

30 lines
1.2 KiB
HTML
Raw Normal View History

2026-01-30 15:07:14 +01:00
{{- $image := partial "helper/image" (dict "Resources" .Page.Resources "Image" .Destination) -}}
{{- $alt := .PlainText | safeHTML -}}
{{- $title := .Title | markdownify -}}
2026-03-04 23:32:33 +01:00
{{/* There are some types of images that don't have width and height attributes, such as SVG */}}
2026-01-30 15:07:14 +01:00
{{- $galleryImage := and $image.Height $image.Width -}}
2026-03-04 23:32:33 +01:00
{{- $attributes := dict -}}
{{- if $galleryImage -}}
{{- $attributes = (dict
"data-flex-grow" (div (mul $image.Width 100) $image.Height)
"data-flex-basis" (printf "%dpx" (div (mul $image.Width 240) $image.Height))
) -}}
{{- end -}}
{{ partial "helper/responsive-image" (dict
"Resource" $image.Resource
"Widths" (cond .Page.Site.Params.ImageProcessing.Content.Enabled .Page.Site.Params.ImageProcessing.Content.Widths nil)
"Attributes" (merge $attributes (dict
"src" $image.Permalink
"width" $image.Width
"height" $image.Height
"alt" $alt
"title" $title
"data-title-escaped" ($title | htmlEscape)
"class" (cond $galleryImage "gallery-image" "")
"loading" "lazy"
"sizes" "(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px"
))
) }}