Loading...
Loading...
Width-based responsive image patterns for Astro. Aspect ratio independent.
npx skill4agent add soborbo/claudeskills astro-imagessizes CSS px × device DPRsizes| Pattern | Width | widths | sizes |
|---|---|---|---|
| FULL | 100vw | | |
| TWO_THIRDS | 66vw | | |
| LARGE | 60vw | | |
| HALF | 50vw | | |
| SMALL | 40vw | | |
| THIRD | 33vw | | |
| QUARTER | 25vw | | |
| FIFTH | 20vw | | |
| SIXTH | 16vw | | |
| Layout | Pattern |
|---|---|
| Full-bleed hero | FULL |
| Split 66/33, 60/40 (image side) | TWO_THIRDS, LARGE |
| Split 50/50, checkerboard | HALF |
| Split 40/60 (text dominant) | SMALL |
| 3-col grid, standing person | THIRD |
| 4-col team grid | QUARTER |
| 5-col icons, 6-col logos | FIFTH, SIXTH |
| Logo, avatar, icon | FIXED |
loading="eager" fetchpriority="high"loading="eager"<Picture
src={image}
widths={[/* from table */]}
sizes="/* from table */"
formats={['avif', 'webp']}
quality={60}
width={/* intrinsic */}
height={/* intrinsic */}
alt="Descriptive text"
decoding="async"
/>loading="eager" fetchpriority="high"decoding---
import { getImage } from 'astro:assets';
const img1x = await getImage({ src: logo, width: 200, quality: 80 });
const img2x = await getImage({ src: logo, width: 400, quality: 60 });
---
<img src={img1x.src} srcset={`${img1x.src} 1x, ${img2x.src} 2x`} width="200" height="50" alt="Logo" /><Picture>widthssizesquality={60}formats={['avif','webp']}/src/assets//public/fetchpriority="high"sizes100vwalt=""<img>sizeswidthheightquality={60}fetchpriority="high"/src/assets/<Picture><img><video>/public/widths={[320,640,960,1200]}/src/assets/schema/og:imageexport default defineConfig({
output: 'server',
adapter: cloudflare()
});
// ⚠️ [WARN] Cloudflare does not support sharp at runtime
// Result: Only original JPGs in dist, no AVIF/WebPexport default defineConfig({
output: 'static',
adapter: cloudflare({
imageService: 'compile'
}),
image: {
service: {
entrypoint: 'astro/assets/services/sharp'
}
}
});output: 'static'prerender: falseimageService: 'compile'image.service.entrypointls dist/_astro/*.avif | head -5 # Should show AVIF files
ls dist/_astro/*.webp | head -5 # Should show WebP filesfind public -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.webp" \) 2>/dev/null
grep -r "<Picture" src --include="*.astro" | grep -v "widths="
grep -r "fetchpriority" src --include="*.astro" | grep -E "\.(map|forEach)\("