pro-laico

images

by pro-laico
atomic-payload
Media & images
v3
>=3.0.0
MIT

Overview

Summary generated from the README

Provides Images and Favicons upload collections that store only the original file. Sized variants are generated on request by a custom endpoint using Sharp, cropped to a focal point, and cached in a hidden purgeable collection. It adds a responsive image component, a focal-point admin field, a favicon picker field and an ImageChild block. Requires Payload 3 and the @pro-laico/core package, with sharp as an optional peer.

Features

  • On-demand resize, crop and recompress of images through a custom endpoint using Sharp
  • Focal-point and aspect-ratio preview field in the admin panel
  • Built-in LQIP placeholder derived from the smallest transform variant
  • ResponsiveImage component rendering a server-side img with a srcset
  • Hidden generated-variants collection with a Purge variants button and automatic purge on change
  • Favicons collection with a FaviconField picker and an ImageChild block factory

Use cases

  • Serve responsive, focal-point-cropped images without pre-generating every size at upload
  • Manage site favicons from a dedicated collection and pick them in other documents
  • Add image blocks to page layouts with blur-up placeholders and cache-busting URLs

From the author

Atomic Payload images package. Provides Images + Favicons Payload upload collections, on-demand Sharp transforms with built-in LQIP placeholders (derived from the smallest variant), a FaviconField helper, an ImageChild block factory, and a plugin factory.

Installation

npm i @pro-laico/images

37

Stars

0

Forks

0

Open Issues

2 months ago

Last Updated

1

Weekly Downloads

v0.5.0

npm Version

265.9 KB

Unpacked Size

1

Dependencies

Repository stars

Trends appear after 7 days of data. Collecting since Oct 22 — 2 daily snapshots so far.

Shared by 10 plugins in pro-laico/atomic-payload.

npm weekly downloads

Trends appear after 7 days of data. Collecting since Oct 22 — 2 daily snapshots so far.

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

Health Score

57/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/1128550352-images.svg)](https://payloaddirectory.dev/plugins/1128550352-images)
HTML
<a href="https://payloaddirectory.dev/plugins/1128550352-images"><img src="https://payloaddirectory.dev/badge/1128550352-images.svg" alt="Payload Directory"></a>
Updated Jul 28, 2026Created Jan 5, 2026Published Jun 27, 2026

README

Atomic Payload Images Plugin

On-demand image handling for Atomic Payload. Uploads store only the original; every rendered size is generated on request by a custom Payload endpoint (resize/crop/recompress with Sharp, cropped to a focal point) and cached as a hidden, purgeable variant collection. Ships a focal-point + ratio-preview admin field, a responsive <img> component (ResponsiveImage, no next/image), a dedicated favicons collection, a favicon-picker field, and an ImageChild block. Part of Atomic Payload.

How it works

  • Upload stores the original only (no pre-generated sizes by default; pregenerateSizes restores the legacy ladder if you want it).
  • Request /api/img/<id>?w&h&ar&fit&q&fmt&v → the endpoint reads the source + its focal point, transforms with Sharp, streams it back same-origin with immutable cache headers, and saves the result to the hidden generatedImages collection (via the configured storage adapter, so it's platform-agnostic).
  • Render with <ResponsiveImage image={…} aspectRatio="16:9" sizes="100vw" /> — a plain, fully server-rendered <img> whose srcset has the settings baked into each URL. The LQIP placeholder is built in and needs no stored field: the wrapper's background is the smallest transform variant (a tiny low-quality crop), which the browser upscales to a soft blur behind the image until the full size loads. Toggle it with the blur prop.
  • Manage derivatives through the variants join on each image, the Purge variants button, and automatic purge on re-upload / focal change / delete.

Cache invalidation. Each transform URL carries a v token derived from the source's filename + focal point (deriveVersion), so replacing the file or moving the focal point yields a new URL — busting otherwise-immutable browser/CDN caches while a metadata-only edit (e.g. alt) leaves it untouched. The server ignores v (focal comes from the doc, and the variant cache key folds it in directly). This only works when you pass a populated doc to <ResponsiveImage>; a bare id has no identity to version, so its URLs omit v.

Environment. Cloud/relative-URL storage adapters are read by self-fetching the server's own static route, so set NEXT_PUBLIC_SERVER_URL to your deployment origin — otherwise generation falls back to http://localhost:3000 and fails in production (surfacing as a 502). The endpoint mounts at a fixed /api/img; only pass path to <ResponsiveImage> / buildSrcset if your Payload API route or Next.js basePath differs from the default.

Atomic Payload dependencies

  • @pro-laico/core — the only required @pro-laico/* dependency (cached image-URL getter, config/cache primitives, and the Get<>/PayloadAugment type system).
  • @pro-laico/atomic — an optional peer, needed only for the ./blocks/imageChild subpath (the Atomic child block). The core image features — the Images collection, the on-demand transform endpoint, ResponsiveImage, the focal point UI, and the placeholder — don't need it, so the package works in any Payload + Next app with just @pro-laico/core.

sharp is an optional peer (required for the transform endpoint; Payload already brings it).

Exports

ImportWhat's there
.The everyday API — imagesPlugin (+ ImagesPluginOptions / TransformEndpointConfig) and the FaviconField helper.
./schemaImage / GeneratedImage schema type stubs for the @pro-laico/core kernel.
./cachegetCachedImage — cached image-URL getter (maps legacy size names to on-demand URLs).
./components/imageResponsiveImage — the responsive <img> component (server- and client-safe).
./components/buildSrcsetgetImageUrl / buildSrcset / buildVariantUrl / deriveVersion — isomorphic URL builders.
./admin/focalPreviewFocal-point + ratio-preview admin field component.
./admin/purgeVariants"Purge variants" admin button component.
./blocks/imageChildImageChild block — createImageBlock factory + prebuilt Image block.
./blocks/imageChild/componentChild block renderer (ResponsiveImage-based).

Similar plugins