From 97b0f98bebc3bdfd9e98750b94cb28ded3f149eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sun, 6 Apr 2025 21:46:51 +0300 Subject: [PATCH] more specific image widths --- assets/_/styles.scss | 20 ++++++++---- layouts/shortcodes/img.html | 64 ++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/assets/_/styles.scss b/assets/_/styles.scss index 8586571..dfd15ec 100644 --- a/assets/_/styles.scss +++ b/assets/_/styles.scss @@ -1,6 +1,12 @@ $bodyText: #333; $border: #999; $headerHover: #f80; +$bodyWidth: 940px; +$contentWidth: $bodyWidth - 220px; + +// image widths: +// half: 324px +// full: 648px * { -webkit-box-sizing: border-box; @@ -20,7 +26,7 @@ table { body { margin: 0 auto; - max-width: 960px; + max-width: $bodyWidth; padding: 10px; color: $bodyText; } @@ -84,16 +90,16 @@ figure.left { float: left; } -img,figcaption { +figure.half { + width: 50%; +} + +img, figcaption { width: 90%; margin: 0 auto; display: block; } -figure.half { - width: 50%; -} - @media (max-width:600px) { img,figcaption, figure.half { width: 100%; @@ -258,7 +264,7 @@ nav#TableOfContents ul { } .content-with-toc { - width: calc(100% - 220px); + width: $contentWidth; margin: 0; } diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index d369dda..0e3e949 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -2,20 +2,20 @@ # Responsive images and resizing -Our picture width is 700 css pixels. "Retina" screens have 2 device pixel ratio +Our picture width is 648 css pixels. "Retina" screens have 2 device pixel ratio (dpr), crazy folks have 4. So the maximum width of the picture we can possibly -care about is 700*4=2800px. +care about is 648*4=2592px. --> {{ $src := resources.GetMatch (.Get "src") | resources.Fingerprint }} {{ $jmax := $src | resources.Fingerprint }} -{{ $j350 := $src.Resize "350x" }} -{{ $j700 := $src.Resize "700x" }} -{{ $j1400 := $src.Resize "1400x" }} -{{ $j2800 := $src.Resize "2800x" }} +{{ $j324 := $src.Resize "324x" }} +{{ $j648 := $src.Resize "648x" }} +{{ $j1296 := $src.Resize "1296x" }} +{{ $j2592 := $src.Resize "2592x" }} -{{ $width := cond (eq (.Get "half") "true") "350px" "700px" }} +{{ $width := cond (eq (.Get "half") "true") "324px" "648px" }} {{ with .Get "hint" }} {{ else }} @@ -23,46 +23,50 @@ care about is 700*4=2800px. {{ end }} {{ $hint := .Get "hint" }} {{ $wmax := $src.Resize (printf "%dx%d webp" $src.Width $src.Height) }} -{{ $w350 := $src.Resize (print "350x webp " $hint ) }} -{{ $w700 := $src.Resize (print "700x webp " $hint ) }} -{{ $w1400 := $src.Resize (print "1400x webp " $hint ) }} -{{ $w2800 := $src.Resize (print "2800x webp " $hint ) }} +{{ $w324 := $src.Resize (print "324x webp " $hint ) }} +{{ $w648 := $src.Resize (print "648x webp " $hint ) }} +{{ $w1296 := $src.Resize (print "1296x webp " $hint ) }} +{{ $w2592 := $src.Resize (print "2592x webp " $hint ) }}