diff --git a/assets/sass/teaser.scss b/assets/sass/teaser.scss index 112dfa71..28df5227 100644 --- a/assets/sass/teaser.scss +++ b/assets/sass/teaser.scss @@ -76,7 +76,6 @@ } .m-teaser__image img { - aspect-ratio: 16/9; border-radius: var(--border-radius-l) var(--border-radius-l) 0 0; object-fit: cover; height: 100%; diff --git a/layouts/partials/image.html b/layouts/partials/image.html index 0dd6495b..8dfc28bd 100644 --- a/layouts/partials/image.html +++ b/layouts/partials/image.html @@ -13,30 +13,41 @@ {{- $name := $image.RelPermalink | strings.TrimSuffix (printf ".%s" $image.MediaType.SubType) -}} {{- $extension := $image.MediaType.SubType -}} - - {{- $widths := slice -}} - {{- if gt $image.Width 500 -}} - {{- $widths = $widths | append 500 -}} - {{- end -}} - {{- if gt $image.Width 800 -}} - {{- $widths = $widths | append 800 -}} - {{- end -}} - {{- if gt $image.Width 1200 -}} - {{- $widths = $widths | append 1200 -}} - {{- end -}} - {{- if gt $image.Width 1500 -}} - {{- $widths = $widths | append 1500 -}} - {{- end -}} - {{- if gt $image.Width 2200 -}} - {{- $widths = $widths | append 2200 -}} - {{- end -}} +{{- $widths := slice -}} +{{- if gt $image.Width 500 -}} + {{- $widths = $widths | append 500 -}} +{{- end -}} +{{- if gt $image.Width 800 -}} + {{- $widths = $widths | append 800 -}} +{{- end -}} +{{- if gt $image.Width 1200 -}} + {{- $widths = $widths | append 1200 -}} +{{- end -}} +{{- if gt $image.Width 1500 -}} + {{- $widths = $widths | append 1500 -}} +{{- end -}} +{{- if gt $image.Width 2200 -}} + {{- $widths = $widths | append 2200 -}} +{{- end -}} - {{- $srcset := slice -}} - {{- range $i, $width := $widths -}} - {{- with $image.Resize (printf "%dx" $width) | resources.Copy (print $name "_" $width "." $extension) -}} - {{- $srcset = $srcset | append (printf "%s %dw" .RelPermalink $width) -}} - {{- end -}} +{{- $srcset := slice -}} +{{- range $i, $width := $widths -}} + {{- with $image.Resize (printf "%dx" $width) | resources.Copy (print $name "_" $width "." $extension) -}} + {{- $srcset = $srcset | append (printf "%s %dw" .RelPermalink $width) -}} {{- end -}} - {{- $srcset = $srcset | append (printf "%s %dw" $image.RelPermalink $image.Width) -}} - {{- printf "\"\"" $image.RelPermalink $loading (delimit $srcset ", ") | safeHTML -}} - +{{- end -}} +{{- $srcset = $srcset | append (printf "%s %dw" $image.RelPermalink $image.Width) -}} + +{{- $styles := "" -}} +{{- if and $image.Width -}} + {{- $styles = printf "aspect-ratio: %d / %d" $image.Width $image.Height -}} +{{- end -}} + +