Skip to content

Commit 398cc44

Browse files
authored
Improve image quality for features (#672)
1 parent 590db1e commit 398cc44

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

docs/src/components/Feature.astro

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ const {
1313
const parsedCaption = asset.caption
1414
? marked.parseInline(asset.caption)
1515
: undefined;
16+
17+
let imageSizes;
18+
19+
if (asset.alignment === "full-width") {
20+
imageSizes =
21+
"(max-width: 375px) 21.5rem, ((min-width: 376px) and (max-width: 799px)) 40rem, ((min-width: 800px) and (max-width: 1050px)) 55.625rem, 71.25rem";
22+
} else {
23+
if (asset.columnSpan === 6) {
24+
imageSizes =
25+
"(max-width: 375px) 21.5rem, ((min-width: 376px) and (max-width: 799px)) 40rem, ((min-width: 800px) and (max-width: 1050px)) 26.8125rem, 34.625rem";
26+
}
27+
28+
if (asset.columnSpan === 8) {
29+
imageSizes =
30+
"(max-width: 375px) 21.5rem, ((min-width: 376px) and (max-width: 799px)) 40rem, ((min-width: 800px) and (max-width: 1050px)) 36.375rem, 46.875rem";
31+
}
32+
}
1633
---
1734

1835
<style>
@@ -149,8 +166,9 @@ const parsedCaption = asset.caption
149166
src={asset.path}
150167
alt={asset.alt}
151168
class="image"
152-
widths={[640, 800, 1200, 1500]}
153-
sizes="(max-width: 375px) 20rem, ((min-width: 376px) and (max-width: 799px)) 40rem, ((min-width: 800px) and (max-width: 1050px)) 37.5rem, 47.5rem"
169+
widths={[360, 640, 800, 1200, 1500, 2000, 2500, 3000, 3420]}
170+
sizes={imageSizes}
171+
quality={95}
154172
/>
155173
) : (
156174
<video

0 commit comments

Comments
 (0)