Image Optimization in Astro — Local vs Cloudinary

Astro has built-in image optimization for local images. For remote images, Cloudinary is the practical choice. Here is when to use each.

Published June 17, 2026
Image optimization comparison

Astro handles local images automatically. Import an image, use the <Image /> component, and Astro converts it to WebP, resizes it, and generates srcset for responsive loading.

import { Image } from 'astro:assets'
import heroImg from '../../assets/hero.jpg'

<Image src={heroImg} alt="Hero" width={1200} height={630} />

Zero config. Works at build time.

When local images aren’t enough

Local images live in your repo. A site with 500 blog posts and 2 images each = 1000 image files in version control. Slow clones. Large repo. Build times increase.

Cloudinary solves this by storing images externally and serving them via URL with transformation parameters.

Steven Doan

Written by

Steven Doan

Freelance web developer. 10+ years building WordPress sites. Now learning Astro in public.

Follow me:

Stay in the loop

New articles on Astro, WordPress, and the modern stack. No spam. Unsubscribe anytime.

UI only — backend coming in a later article.

Related Posts

📦 This is a live demo project

Built step by step in the series Learn Astro from Scratch — read the full guide on doancongtuan.com.