Skip to content

Commit

Permalink
Handle svg hero images in blocks/cover shortcode (#1505)
Browse files Browse the repository at this point in the history
  • Loading branch information
fekete-robert committed Feb 2, 2024
1 parent 9352504 commit e22aec4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions layouts/shortcodes/blocks/cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
{{ $height := .Get "height" | default "max" -}}

{{ with $promo_image -}}
{{ $promo_image_big := (.Fill (printf "1920x1080 %s" $image_anchor)) -}}
{{ $promo_image_small := (.Fill (printf "960x540 %s" $image_anchor)) -}}
{{ $promo_image_big := . -}}
{{ $promo_image_small := . -}}
{{ if ne $promo_image.MediaType.SubType "svg" -}}
{{ $promo_image_big = .Fill (printf "1920x1080 %s" $image_anchor) -}}
{{ $promo_image_small = .Fill (printf "960x540 %s" $image_anchor) -}}
{{ end -}}
<link rel="preload" as="image" href="{{ $promo_image_small.RelPermalink }}" media="(max-width: 1200px)">
<link rel="preload" as="image" href="{{ $promo_image_big.RelPermalink }}" media="(min-width: 1200px)">
<style>
Expand Down

0 comments on commit e22aec4

Please sign in to comment.