Image

Image creates optimized images with accessible figcaptions and prevents cumulative layout shift. It uses Astro’s Picture component under the hood.


Prevent cumulative layout shift without additional work

Google has been extremely vocal about the importance of Cumulative Layout Shift (CLS), so much that it has became part of Google’s Lighthouse audit.

Thankfully, Astro’s built-in Image and Picture components handles CLS without us having to lift a finger.

index.astro
---
import { Image } from 'astro:assets'
import image1 from '../image1.jpg'
---
<Image src={image1} alt="..." />

Super easy Dynamic Image Import

Unfortunately, Astro’s built in Image and Picture elements require you to manually import your image, which leaves more to be desired.

We’ve built Image so you can import images dynamically just like how you’ve been using images all along.

---
import { Image } from 'astro:assets'
import image1 from '../image1.jpg'
---
<Image src={image1} alt="..." />

Include accessible Figcaptions with a single property

It’s strange, but <figcaption> elements aren’t accessible. You gotta work out a few quirks to make them accessible. We’ve done this for you so you can just add caption and call it a day.

---
import { Image } from '@splendidlabz/astro'
---
<Image
src='...'
alt="image alt"
caption="image caption"
/>

Automatic AVIF and Webp formats

There are lots of image formats out there, but the most performant ones are avif and webp. We’ve built these two formats into Image so you can optimize your images without any extra work.

---
import { Image } from '@splendidlabz/astro'
---
<Image ... formats={['avif', 'webp']} />

Automatic srcset for improved responsive image performance

Image includes srcset sizes at 600, 900, 1200, 1500 and 1800 pixels to serve appropriate images for almost every device users can use. This lowers your page weight as much as possible.

These values are customizable if you wish to change them.

---
import { Image } from '@splendidlabz/astro'
---
<Image ... widths={['600', '1200']} />