Adds a readonly blurhash field to upload-enabled collections you choose and computes a BlurHash string for each uploaded image. It is registered through the plugins array in the Payload config. Encoding can be tuned with resize width and height and X and Y component counts, and the plugin can be toggled on or off. Supports Payload 1.7.2 and 2.x; imageSizes are not yet supported.
Dead simple BlurHash auto generation plugin for Payload CMS
Installation
npm i @zapal/payload-blurhash-plugin8
Stars
0
Forks
1
Open Issues
2 years ago
Last Updated
6
Weekly Downloads
v1.0.7
npm Version
43.0 KB
Unpacked Size
1
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/706679910-root)<a href="https://payloaddirectory.dev/plugins/706679910-root"><img src="https://payloaddirectory.dev/badge/706679910-root.svg" alt="Payload Directory"></a>README
Turbocharge your website performance by creating ultralight image placeholders, resulting in a smoother user experience.
1.7.2 or higher is required (version 2.0.0 or higher is recommended)Instal the package with yarn add @zapal/payload-blurhash-plugin or npm install @zapal/payload-blurhash-plugin
Now setup the plugin within your payload.config.ts file as follows:
import { buildConfig } from 'payload/config';
import { blurHash } from '@zapal/payload-blurhash-plugin';
import path from 'path';
/* ... */
export default buildConfig({
plugins: [
blurHash({
collections: ['team-photos-collection', 'blog-images-collection'],
}),
],
/* ... */
});
The plugin will generate a readonly blurhash field for each image uploaded to the specified collections. Generation
for imageSizes are not supported yet (but it's in progress).
The proper way to conditionally enable/disable this plugin is to use the enabled property.
blurHash({
enabled: process.env.ENABLE_BLURHASH_PLUGIN === 'true',
collections: ['team-photos-collection', 'blog-images-collection'],
}),
This plugin is configurable to work across upload-enabled Payload collections. A * denotes that the property is
required.
| Option | Type | Description |
|---|---|---|
collections * | string[] | Array of upload-enabled collections' slugs you want to enable the plugin for. |
enabled | boolean | Conditionally enable/disable plugin. Default: true. |
width | number | Width to resize the image before computing the blurhash. Default: 32. |
height | number | Height to resize the image before computing the blurhash. Default: 32. |
componentX | number | X component count to pass to the blurhash encoder. Default: 3. |
componentY | number | Y component count to pass to the blurhash encoder. Default: 3. |
See more information about the width, height, componentX, componentY options and BlurHash encoder
here.
You can find the source code in the src directory. For development purposes, you can use the dev directory with all
the necessary files to test the plugin in a Payload project. Also we are strongly recommending to use your IDE debugger
instead of console.log statements.
You need to follow these steps to start developing and testing the plugin locally:
dev directory (cd dev).env file (cp .env.example .env).env filenpm i)npm run dev)And you are ready to go!
We are open to, and grateful for, any contributions made by the community.
We are planning to add more features to this plugin in the future. If you have any ideas, create an issue to discuss it.
Next steps (v1):
imageSizes (in progress)Next steps (v2):
This project is licensed under the MIT License
payload plugin aspect preview
Crop and focal point editing with live multi-aspect-ratio previews for Payload upload collections
7534/wk6v3
blur data urls
Generates blur placeholder data URLs for images uploaded to Payload media collections
6966/wk83v3
payload media
Search Unsplash, Pexels and Pixabay stock images and videos from Payload upload collections
680/wk8v4
images
On-demand Sharp image transforms with focal points, built-in blur placeholders and a favicons collection
570/wk37v3
payload icons
SVG icon upload collection with automatic optimization and a server component to render icons inline
560/wk18v3
payload images
On-demand Sharp image transforms with focal-point cropping, placeholders and a responsive image component
550/wk18v3