invakid404

payload blurhash plugin

by invakid404
Media & images
v?
v3.0.0-beta.76
Unlicense

Overview

Summary generated from the README

Adds automatic image placeholder encoding to Payload upload collections. Add it to the plugins array in the Payload config; it applies to all upload collections by default or to the collections you list. Supports the blurhash algorithm and the thumbhash algorithm, with versions available for Payload v2 and v3.

Features

  • Automatic Blurhash encoding of uploaded images
  • Optional thumbhash algorithm
  • Limit to selected collections via a slug list
  • Configurable MIME type pattern, defaulting to images
  • Tunable blurhash width, height and component counts
  • Optional display of the hash field in the admin

Use cases

  • Show blurred placeholders while images load on a Payload-powered frontend
  • Generate compact image previews for media collections without manual work

From the author

Payload CMS plugin for automatic Blurhash encoding of images

Installation

npm i payload-blurhash-plugin

95

Stars

7

Forks

7

Open Issues

1 years ago

Last Updated

1.1k

Weekly Downloads

v3.1.0

npm Version

94.4 KB

Unpacked Size

3

Dependencies

GitHub stars

95+2 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202695
Dec 5, 202695
Dec 4, 202695
Dec 3, 202695
Dec 2, 202695
Dec 1, 202695
Nov 30, 202695
Nov 29, 202695
Nov 28, 202695
Nov 27, 202695
Nov 26, 202695
Nov 25, 202695
Nov 24, 202695
Nov 23, 202695
Nov 22, 202695
Nov 21, 202695
Nov 20, 202695
Nov 19, 202695
Nov 18, 202695
Nov 17, 202695
Nov 16, 202696
Nov 15, 202696
Nov 14, 202696
Nov 13, 202696
Nov 12, 202696
Nov 11, 202696
Nov 10, 202695
Nov 9, 202695
Nov 8, 202695
Nov 7, 202695
Nov 6, 202695
Nov 5, 202694
Nov 4, 202694
Nov 3, 202694
Nov 2, 202694
Nov 1, 202694
Oct 31, 202694
Oct 30, 202694
Oct 29, 202694
Oct 28, 202694
Oct 27, 202694
Oct 26, 202694
Oct 25, 202694
Oct 24, 202694
Oct 23, 202694
Oct 22, 202694
Oct 21, 202693
Oct 20, 202693
Oct 19, 202693
Oct 18, 202693
Oct 17, 202693
Oct 16, 202693
Oct 15, 202693
Oct 14, 202693
Oct 13, 202693
Oct 12, 202693
Oct 11, 202693
Oct 10, 202693
Oct 9, 202693
Oct 8, 202693
Oct 7, 202693
Oct 6, 202693
Oct 5, 202693
Oct 4, 202693
Oct 3, 202693
Oct 2, 202693
Oct 1, 202693
Sep 30, 202693
Sep 29, 202693
Sep 28, 202693
Sep 27, 202693
Sep 26, 202693
Sep 25, 202693
Sep 24, 202693
Sep 23, 202693
Sep 22, 202693
Sep 21, 202693
Sep 20, 202693
Sep 19, 202693
Sep 18, 202693
Sep 17, 202693
Sep 16, 202693
Sep 15, 202693
Sep 14, 202693
Sep 13, 202693
Sep 12, 202693
Sep 11, 202693
Sep 10, 202693
Sep 9, 202693
Sep 8, 202693
Sep 7, 202693
npm weekly downloads

1.1K−816 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 20261,082
Dec 5, 20261,190
Dec 4, 20261,231
Dec 3, 20261,248
Dec 2, 20261,257
Dec 1, 20261,325
Nov 30, 20261,303
Nov 29, 20261,191
Nov 28, 20261,132
Nov 27, 20261,295
Nov 26, 20261,420
Nov 25, 20261,623
Nov 24, 20261,648
Nov 23, 20261,654
Nov 22, 20261,709
Nov 21, 20261,819
Nov 20, 20261,884
Nov 19, 20262,091
Nov 18, 20262,029
Nov 17, 20262,092
Nov 16, 20262,124
Nov 15, 20262,049
Nov 14, 20261,953
Nov 13, 20261,805
Nov 12, 20261,670
Nov 11, 20261,504
Nov 10, 20261,369
Nov 9, 20261,351
Nov 8, 20261,425
Nov 7, 20261,506
Nov 6, 20261,455
Nov 5, 20261,348
Nov 4, 20261,337
Nov 3, 20261,442
Nov 2, 20261,431
Nov 1, 20261,246
Oct 31, 20261,213
Oct 30, 20261,197
Oct 29, 2026985
Oct 28, 2026800
Oct 27, 2026705
Oct 26, 2026867
Oct 25, 20261,018
Oct 24, 2026995
Oct 23, 2026827
Oct 22, 20261,007
Oct 21, 20261,242
Oct 20, 20261,281
Oct 19, 20261,100
Oct 18, 2026984
Oct 17, 2026940
Oct 16, 20261,084
Oct 15, 20261,170
Oct 14, 20261,244
Oct 13, 20261,370
Oct 12, 20261,512
Oct 11, 20261,592
Oct 10, 20261,722
Oct 9, 20262,136
Oct 8, 20262,229
Oct 7, 20262,317
Oct 6, 20262,127
Oct 5, 20261,921
Oct 4, 20261,872
Oct 3, 20261,853
Oct 2, 20261,767
Oct 1, 20261,612
Sep 30, 20261,466
Sep 29, 20261,564
Sep 28, 20261,602
Sep 27, 20261,573
Sep 26, 20261,583
Sep 25, 20261,464
Sep 24, 20261,451
Sep 23, 20261,414
Sep 22, 20261,345
Sep 21, 20261,430
Sep 20, 20261,465
Sep 19, 20261,610
Sep 18, 20261,515
Sep 17, 20261,597
Sep 16, 20261,635
Sep 15, 20261,616
Sep 14, 20261,573
Sep 13, 20261,559
Sep 12, 20261,334
Sep 11, 20261,459
Sep 10, 20261,662
Sep 9, 20261,878
Sep 8, 20261,930
Sep 7, 20261,898

Each point is npm's rolling 7-day download count.

Health Score

50/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/497083627-root.svg)](https://payloaddirectory.dev/plugins/497083627-root)
HTML
<a href="https://payloaddirectory.dev/plugins/497083627-root"><img src="https://payloaddirectory.dev/badge/497083627-root.svg" alt="Payload Directory"></a>
Updated Feb 14, 2025Created May 27, 2022Published Feb 14, 2025

README

payload-blurhash-plugin

Payload CMS plugin for automatic Blurhash encoding of images.

Getting started

  1. Install the package
  • Payload v2: npm i payload-blurhash-plugin@2
  • Payload v3: npm i payload-blurhash-plugin@3
  1. Add the plugin to your payload.config.ts:
import computeBlurhash from 'payload-blurhash-plugin';

export default buildConfig({
  /* ... */
  plugins: [computeBlurhash()],
});

Plugin options

Optionally, you can pass the following options to tweak the behavior of the plugin:

export type BlurhashPluginOptions = {
  /*
   * Array of collection slugs that the plugin should apply to.
   * By default, the plugin will apply to all collections with `upload` properties.
   */
  collections?: CollectionConfig['slug'][];

  /*
   * Pattern to determine which MIME types to target
   * Default: image/*
   */
  mimeTypePattern?: string;

  /*
   * Whether to show the Blurhash field when viewing media items in the admin interface.
   * Default: false
   */
  showBlurhashField?: boolean;
} & AlgorithmOptions;

The AlgorithmOptions depend on which algorithm you are using. Currently, there are two algorithms available: "blurhash" (the default) and "thumbhash". You can select an algorithm by specifying the algorithm name under the algorithm key.

These are the options for the "blurhash" algorithm:

type BlurhashOptions = {
  // Default: 32
  width?: number | undefined;
  // Default: 32
  height?: number | undefined;
  // Default: 3
  componentX?: number | undefined;
  // Default: 3
  componentY?: number | undefined;
};

There are currently no options for the "thumbhash" algorithm.

The defaults are chosen somewhat arbitrarily, they are just values that I've found to work nicely for me.

Similar plugins