diff --git a/layouts/shortcodes/picture.html b/layouts/shortcodes/picture.html index ffe742e..3c95d49 100644 --- a/layouts/shortcodes/picture.html +++ b/layouts/shortcodes/picture.html @@ -1,3 +1,4 @@ +{{ $light_gif := resources.GetMatch (printf "/p/%s.gif" (.Get "name")) -}} {{ $light_svg := resources.GetMatch (printf "/p/%s.svg" (.Get "name")) -}} {{ $light_png := resources.GetMatch (printf "/p/%s.png" (.Get "name")) -}} {{ $light_jpg := resources.GetMatch (printf "/p/%s.jpg" (.Get "name")) -}} @@ -5,6 +6,7 @@ {{ $light_avif := resources.GetMatch (printf "/p/%s.avif" (.Get "name")) -}} {{ $light_jxl := resources.GetMatch (printf "/p/%s.jxl" (.Get "name")) -}} {{ $dark_svg := resources.GetMatch (printf "/p/%s_dark.svg" (.Get "name")) -}} +{{ $dark_gif := resources.GetMatch (printf "/p/%s_dark.gif" (.Get "name")) -}} {{ $dark_png := resources.GetMatch (printf "/p/%s_dark.png" (.Get "name")) -}} {{ $dark_jpg := resources.GetMatch (printf "/p/%s_dark.jpg" (.Get "name")) -}} {{ $dark_webp := resources.GetMatch (printf "/p/%s_dark.webp" (.Get "name")) -}} @@ -19,12 +21,30 @@ {{- $orig_img_type = "image/jpeg" -}} {{- $orig_img = $light_jpg -}} {{- end -}} +{{- with $light_gif -}} + {{- $orig_img_type = "image/gif" -}} + {{- $orig_img = $light_gif -}} +{{- end -}} {{- with $dark_jpg -}} {{- $orig_img_dark_type = "image/jpeg" -}} {{- $orig_img_dark = $dark_jpg -}} {{- end -}} -{{- $img_width := $orig_img.Width -}} -{{- $img_height := $orig_img.Height -}} +{{- with $dark_gif -}} + {{- $orig_img_dark_type = "image/gif" -}} + {{- $orig_img_dark = $dark_gif -}} +{{- end -}} +{{- $img_width := 0 -}} +{{- with .Get "width" -}} + {{- $img_width = . -}} +{{- else -}} + {{- $img_width = $orig_img.Width -}} +{{- end -}} +{{- $img_height := 0 -}} +{{- with .Get "height" -}} + {{- $img_height = . -}} +{{- else -}} + {{- $img_height = $orig_img.Height -}} +{{- end -}} {{- with (.Get "sf") -}} {{- $img_width = (mul $img_width . | math.Round) -}} {{- $img_height = (mul $img_height . | math.Round ) -}}