@unpic/astro

1.0.0 • Public • Published

tree

@unpic/astro

A high-performance, responsive image service and component library for Astro. Generates a responsive <img> tag that follows best practices, with the correct srcset, sizes and styles. Detects image URLs from most image CDNs and CMSs and can resize images with no build step.

@unpic/astro has two parts, which can be used independently but work best together:

  • A component library which provides a <Image> component and a <Source> component for art direction.
  • An Astro image service, which allows you to use the regular Astro Image component unchanged, and have it automatically generate the correct srcset and attributes for all images.

Features

  • Just an <img> tag! No extra elements, no runtime JavaScript. Easy to style.
  • Automatically generates correct srcset and sizes attributes for responsive images
  • Handles responsive resizing of images, preserving aspect ratio
  • Uses native lazy loading and aync decoding for offscreen images
  • Handles different image layouts: fixed, constrained and full width
  • Uses eager loading and high priority fetching for important images
  • Delivers modern image formats, including WebP and AVIF if supported by your browser
  • No built step or server-side rendering required: uses your existing image CDN or CMS, with no additional configuration
  • Supports most image CDNs and headless CMSs, including Cloudinary, Contentful, Imgix, and Shopify
  • Generates image placeholders to display while images are loading.

Installation and usage

npm install @unpic/astro
---
import { Image } from "@unpic/astro";
---

<Image
  src="https://cdn.shopify.com/static/sample-images/bath_gcrop_center.jpeg"
  layout="constrained"
  width={800}
  height={600}
  alt="A lovely bath"
/>

For the supported props, see the docs.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.0
441latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.0
441
0.1.0
82
0.0.47627
0.0.4639
0.0.447
0.0.43
7
0.0.42
1
0.0.412
0.0.40
1
0.0.39
0
0.0.38
0
0.0.370
0.0.36
2
0.0.35
1
0.0.34
0
0.0.33
0
0.0.32
0
0.0.31
0
0.0.30
0
0.0.29
0
0.0.28
0
0.0.27
0
0.0.26
0
0.0.25
0
0.0.24
0
0.0.23
2
0.0.22
0
0.0.21
0
0.0.20
0
0.0.19
0
0.0.18
0
0.0.17
1
0.0.16
0
0.0.15
0
0.0.140
0.0.130
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.11

Package Sidebar

Install

npm i @unpic/astro

Weekly Downloads

1,214

Version

1.0.0

License

MIT

Unpacked Size

17.8 kB

Total Files

15

Last publish

Collaborators

  • ascorbic