commit af2f63ac1820b3828089d2d7e971303eb1edd6f6 parent b16005fd7e0086c99e451fa9458e109f02dbec1f Author: Yohanes Bandung Bondowoso <hi@ybbond.id> Date: Fri, 2 Apr 2021 05:41:51 +0700 refactor: more responsive render-image for small images Diffstat:
| M | layouts/_default/_markup/render-image.html | | | 23 | ++++++++++++++++++----- |
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html @@ -8,13 +8,26 @@ {{ $title = .Title }} {{ end }} -{{ $width := "400px" }} +{{ $width := "380px" }} {{ $height := "520px" }} +{{ $orientation := "portrait" }} -{{- if gt $image.Width $image.Height }} -{{ $width = "520px" }} -{{ $height = "380px" }} -{{- end }} +{{- if gt $image.Width $image.Height -}} + {{ $orientation = "landscape" }} + {{ $width = "520px" }} + {{ $height = "380px" }} + {{ if gt "300" $image.Width -}} + {{ $width = "300px" }} + {{ $height = "170px" }} + {{ end -}} +{{- end -}} + +{{- if eq $orientation "portrait" -}} + {{ if gt "300" $image.Height -}} + {{ $width = "170px" }} + {{ $height = "300px" }} + {{ end -}} +{{- end -}} <figure class="image-figure"> <center>