Closed angeloashmore closed 2 years ago
Merging #24 (ce393c5) into main (5232b14) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## main #24 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 8 11 +3
Lines 528 683 +155
Branches 24 34 +10
==========================================
+ Hits 528 683 +155
Impacted Files | Coverage Δ | |
---|---|---|
src/PrismicNextImage.tsx | 100.00% <100.00%> (ø) |
|
src/index.ts | 100.00% <100.00%> (ø) |
|
src/lib/__PRODUCTION__.ts | 100.00% <100.00%> (ø) |
|
src/lib/devMsg.ts | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 5232b14...ce393c5. Read the comment docs.
Path | Size |
---|---|
dist/index.js | 3.25 KB (+37.19% 🔺) |
./dist/index.cjs | 7.61 KB (+7.05% 🔺) |
Types of changes
Description
This PR adds a
<PrismicNextImage>
component that renders Prismic Image fields using Next.js'next/image
component.It is a light wrapper around
next/image
designed specifically for Prismic fields. It automatically provides the field's alt text and dimensions tonext/image
.Imgix URL loader (or pick your own)
It includes a custom
next/image
loader to optimize images using the Imgix URL API, which all images uploaded to Prismic support.To fall back to the Next.js Image Optimization API or use the loader defined in
next.config.js
, passloader={undefined}
.Like the base
next/image
component, a loader can be explicitly passed to the component.The source URL will contain any transformations via the Imgix URL (if given), even when using a loader different from the built-in one. See the next section for details.
Editing images with Imgix
Images can be edited through the image's URL parameters. This includes transformations like saturation, cropping, and blurring.
Arbitrary Imgix parameters can be provided using the
imgixParams
prop. See Imgix's Image URL API Reference for a full list of what's available.The
src
URL and each URL insrcset
will contain thesat: -100
URL parameter as a result:Credit
Thanks to @asyarb for sharing code that
<PrismicNextImage>
is based on.Checklist:
🖼️