pro-laico

payload images

by pro-laico
payload-plugins
Media & images
v3
^3.0.0
MIT

Overview

Summary generated from the README

Adds an Images upload collection that stores only the original file and generates, crops and caches each rendered size on first request using Sharp. Includes an admin focal-point picker, upload-time placeholder and palette metadata, and a ResponsiveImage React component. Requires Payload 3, React 19, sharp and Next.js 15 or later with the App Router.

Features

  • On-demand Sharp transform endpoint with focal-aware cropping and format negotiation
  • Durable variant cache with two-way purge
  • Admin focal-point picker with saliency-based initial focal point
  • Opt-in blur placeholders as BlurHash tiers and micro-webp data URIs
  • Optional smart prewarming of commonly served variants through Payload Jobs
  • Backfill command to stamp metadata on existing images

Use cases

  • Serve responsive, correctly cropped images from a single uploaded original
  • Add blur placeholders and color palettes to existing media libraries
  • Reduce storage by avoiding pre-generated image size variants

From the author

Image optimization for Payload CMS: an Images upload collection that stores only the original, an on-demand Sharp transform endpoint (focal-aware crop, format negotiation, built-in LQIP placeholders), a durable variant cache with two-way purge, an admin focal-point picker, and a responsive <ResponsiveImage> component.

Installation

npm i @pro-laico/payload-images

18

Stars

1

Forks

1

Open Issues

3 months ago

Last Updated

49

Weekly Downloads

v0.8.5

npm Version

1.0 MB

Unpacked Size

0

Dependencies

Repository stars

18+2 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 202618
Dec 5, 202618
Dec 4, 202618
Dec 3, 202618
Dec 2, 202618
Dec 1, 202618
Nov 30, 202618
Nov 29, 202618
Nov 28, 202618
Nov 27, 202619
Nov 26, 202619
Nov 25, 202619
Nov 24, 202619
Nov 23, 202619
Nov 22, 202619
Nov 21, 202619
Nov 20, 202619
Nov 19, 202619
Nov 18, 202619
Nov 17, 202618
Nov 16, 202618
Nov 15, 202618
Nov 14, 202618
Nov 13, 202618
Nov 12, 202618
Nov 11, 202618
Nov 10, 202618
Nov 9, 202618
Nov 8, 202618
Nov 7, 202618
Nov 6, 202618
Nov 5, 202618
Nov 4, 202618
Nov 3, 202618
Nov 2, 202618
Nov 1, 202618
Oct 31, 202618
Oct 30, 202618
Oct 29, 202618
Oct 28, 202618
Oct 27, 202618
Oct 26, 202618
Oct 25, 202618
Oct 24, 202618
Oct 23, 202618
Oct 22, 202618
Oct 21, 202617
Oct 20, 202617
Oct 19, 202617
Oct 18, 202617
Oct 17, 202617
Oct 16, 202617
Oct 15, 202617
Oct 14, 202617
Oct 13, 202617
Oct 12, 202617
Oct 11, 202617
Oct 10, 202617
Oct 9, 202617
Oct 8, 202617
Oct 7, 202617
Oct 6, 202617
Oct 5, 202617
Oct 4, 202617
Oct 3, 202617
Oct 2, 202616
Oct 1, 202616
Sep 30, 202616
Sep 29, 202616
Sep 28, 202616
Sep 27, 202616
Sep 26, 202616
Sep 25, 202616
Sep 24, 202616
Sep 23, 202616
Sep 22, 202616
Sep 21, 202616
Sep 20, 202616
Sep 19, 202616
Sep 18, 202616
Sep 17, 202616
Sep 16, 202616
Sep 15, 202616
Sep 14, 202616
Sep 13, 202616
Sep 12, 202616
Sep 11, 202616
Sep 10, 202616
Sep 9, 202616
Sep 8, 202616
Sep 7, 202616

Shared by 7 plugins in pro-laico/payload-plugins.

npm weekly downloads

49+18 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202649
Dec 5, 202620
Dec 4, 202621
Dec 3, 202622
Dec 2, 20265
Dec 1, 202625
Nov 30, 202624
Nov 29, 202623
Nov 28, 202623
Nov 27, 202622
Nov 26, 202623
Nov 25, 202624
Nov 24, 20264
Nov 23, 20264
Nov 22, 20267
Nov 21, 20266
Nov 20, 20267
Nov 19, 20268
Nov 18, 202621
Nov 17, 202621
Nov 16, 202622
Nov 15, 202621
Nov 14, 202622
Nov 13, 202621
Nov 12, 202618
Nov 11, 20264
Nov 10, 202621
Nov 9, 202620
Nov 8, 202632
Nov 7, 202631
Nov 6, 202632
Nov 5, 202632
Nov 4, 202637
Nov 3, 202620
Nov 2, 202624
Nov 1, 202619
Oct 31, 202619
Oct 30, 202618
Oct 29, 202618
Oct 28, 202613
Oct 27, 202615
Oct 26, 202611
Oct 25, 20263
Oct 24, 20263
Oct 23, 20263
Oct 22, 20266
Oct 21, 20269
Oct 20, 20268
Oct 19, 202610
Oct 18, 20269
Oct 17, 20269
Oct 16, 202622
Oct 15, 202624
Oct 14, 202623
Oct 13, 202624
Oct 12, 202622
Oct 11, 202638
Oct 10, 202638
Oct 9, 202625
Oct 8, 202620
Oct 7, 202618
Oct 6, 202625
Oct 5, 202626
Oct 4, 202625
Oct 3, 202626
Oct 2, 202626
Oct 1, 202627
Sep 30, 202627
Sep 29, 202627
Sep 28, 202626
Sep 27, 202611
Sep 26, 202623
Sep 25, 202625
Sep 24, 202624
Sep 23, 202638
Sep 22, 202631
Sep 21, 202647
Sep 20, 202648
Sep 19, 202637
Sep 18, 202636
Sep 17, 202645
Sep 16, 202633
Sep 15, 202632
Sep 14, 202617
Sep 13, 202618
Sep 12, 202618
Sep 11, 202617
Sep 10, 202611
Sep 9, 202612
Sep 8, 202631
Sep 7, 202631

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

Health Score

54/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/1281664108-payload-images.svg)](https://payloaddirectory.dev/plugins/1281664108-payload-images)
HTML
<a href="https://payloaddirectory.dev/plugins/1281664108-payload-images"><img src="https://payloaddirectory.dev/badge/1281664108-payload-images.svg" alt="Payload Directory"></a>
Updated Aug 14, 2026Created Jun 26, 2026Published Aug 14, 2026

README

@pro-laico/payload-images

On-demand image optimization for Payload CMS — an Images collection that stores only the original and generates, crops, and caches each rendered size on first request, with a responsive <ResponsiveImage> component and admin focal-point picker.

pnpm add @pro-laico/payload-images

Requires Payload ^3, React 19, sharp, and Next.js 15+ (App Router). Not framework-agnostic: the transform endpoint, prewarming, and preset generation persist variants with Next's after().

Fetch images Sanity-style — seed createImageFor once with your app's Payload handle, then one chain resolves the render-ready doc (src/srcset/alt/placeholder), ready to spread into <ResponsiveImage>:

export const imageFor = createImageFor(getPayload({ config }))

const img = await imageFor(post.hero).aspectRatio('16:9').blur('md').fetch()
if (img) return <ResponsiveImage {...img} alt={img.alt ?? ''} sizes="50vw" />

Opt into smart prewarming (prewarm: true) and the endpoint learns which renders the site actually serves, pre-generating exactly those variants for new/replaced images via a deferred Payload Job — the first visitor never pays the transform.

Placeholders are a quality-tier ladder stored on the doc at upload time: five BlurHash strings (xs…xl) plus two micro-webp data URIs (xxl/x3). They're opt-in per read: a read that requests a blur (.blur('md') / context: { blur }) gets a finished, focal-cropped data URI back from the virtual placeholder field — the processing happens in the field hook, and <ResponsiveImage> just paints it. Reads that don't ask get null, so small images never carry inline data-URI weight in the HTML. The same upload-time decode also stores a Sanity-style color palette, hasAlpha/isOpaque flags, and a saliency-based initial focal point (applied only when the editor hasn't picked one).

Migrating an existing project

Images uploaded before the metadata hook carry no tiers/palette (reads degrade gracefully — no placeholder, nothing breaks). Stamp them once with the bundled command:

payload images:backfill                    # only images missing metadata (idempotent)
payload images:backfill --force            # regenerate every image
payload images:backfill --focal            # also set the saliency focal on docs still at 50/50
payload images:backfill --collection media # a custom source collection

--focal is opt-in because it changes crops on a live site. New uploads and file replacements analyze themselves via the upload hook.

Documentation →

Ported from @pro-laico/images (Atomic Payload, MIT).

Similar plugins