Adds a live preview grid to configured upload collections so editors can adjust a crop or focal point and see the framing across several aspect ratios at once. It replaces the collection's upload UI and adds an aspectPreview UI field, with edits stored through Payload's upload workflow. Requires Payload and @payloadcms/ui 3.85 or newer and React 19. A standalone React editor component is also exported.
Payload CMS plugin for image cropping, focal point editing, and live responsive image previews across hero, card, and mobile aspect ratios.
Installation
npm i payload-plugin-aspect-preview6
Stars
0
Forks
0
Open Issues
2 weeks ago
Last Updated
174
Weekly Downloads
v0.4.0
npm Version
112.1 KB
Unpacked Size
1
Dependencies
60 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 6 |
| Dec 5, 2026 | 6 |
| Dec 4, 2026 | 6 |
| Dec 3, 2026 | 6 |
| Dec 2, 2026 | 6 |
| Dec 1, 2026 | 6 |
| Nov 30, 2026 | 6 |
| Nov 29, 2026 | 6 |
| Nov 28, 2026 | 6 |
| Nov 27, 2026 | 6 |
| Nov 26, 2026 | 6 |
| Nov 25, 2026 | 6 |
| Nov 24, 2026 | 6 |
| Nov 23, 2026 | 6 |
| Nov 22, 2026 | 6 |
| Nov 21, 2026 | 6 |
| Nov 20, 2026 | 6 |
| Nov 19, 2026 | 6 |
| Nov 18, 2026 | 6 |
| Nov 17, 2026 | 6 |
| Nov 16, 2026 | 6 |
| Nov 15, 2026 | 6 |
| Nov 14, 2026 | 6 |
| Nov 13, 2026 | 6 |
| Nov 12, 2026 | 6 |
| Nov 11, 2026 | 6 |
| Nov 10, 2026 | 6 |
| Nov 9, 2026 | 6 |
| Nov 8, 2026 | 6 |
| Nov 7, 2026 | 6 |
| Nov 6, 2026 | 6 |
| Nov 5, 2026 | 6 |
| Nov 4, 2026 | 6 |
| Nov 3, 2026 | 6 |
| Nov 2, 2026 | 6 |
| Nov 1, 2026 | 6 |
| Oct 31, 2026 | 6 |
| Oct 30, 2026 | 6 |
| Oct 29, 2026 | 6 |
| Oct 28, 2026 | 6 |
| Oct 27, 2026 | 6 |
| Oct 26, 2026 | 6 |
| Oct 25, 2026 | 6 |
| Oct 24, 2026 | 6 |
| Oct 23, 2026 | 6 |
| Oct 22, 2026 | 6 |
| Oct 21, 2026 | 6 |
| Oct 20, 2026 | 6 |
| Oct 19, 2026 | 6 |
| Oct 18, 2026 | 6 |
| Oct 17, 2026 | 6 |
| Oct 16, 2026 | 6 |
| Oct 15, 2026 | 6 |
| Oct 14, 2026 | 6 |
| Oct 13, 2026 | 6 |
| Oct 12, 2026 | 6 |
| Oct 11, 2026 | 6 |
| Oct 10, 2026 | 6 |
| Oct 9, 2026 | 6 |
| Oct 8, 2026 | 6 |
| Oct 7, 2026 | 6 |
| Oct 6, 2026 | 6 |
| Oct 5, 2026 | 6 |
| Oct 4, 2026 | 6 |
| Oct 3, 2026 | 6 |
| Oct 2, 2026 | 6 |
| Oct 1, 2026 | 6 |
| Sep 30, 2026 | 6 |
| Sep 29, 2026 | 6 |
| Sep 28, 2026 | 6 |
| Sep 27, 2026 | 6 |
| Sep 26, 2026 | 6 |
| Sep 25, 2026 | 6 |
| Sep 24, 2026 | 6 |
| Sep 23, 2026 | 6 |
| Sep 22, 2026 | 6 |
| Sep 21, 2026 | 6 |
| Sep 20, 2026 | 6 |
| Sep 19, 2026 | 6 |
| Sep 18, 2026 | 6 |
| Sep 17, 2026 | 6 |
| Sep 16, 2026 | 6 |
| Sep 15, 2026 | 6 |
| Sep 14, 2026 | 6 |
| Sep 13, 2026 | 6 |
| Sep 12, 2026 | 6 |
| Sep 11, 2026 | 6 |
| Sep 10, 2026 | 6 |
| Sep 9, 2026 | 6 |
| Sep 8, 2026 | 6 |
| Sep 7, 2026 | 6 |
128+101 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 128 |
| Dec 5, 2026 | 142 |
| Dec 4, 2026 | 145 |
| Dec 3, 2026 | 131 |
| Dec 2, 2026 | 137 |
| Dec 1, 2026 | 127 |
| Nov 30, 2026 | 123 |
| Nov 29, 2026 | 158 |
| Nov 28, 2026 | 157 |
| Nov 27, 2026 | 330 |
| Nov 26, 2026 | 313 |
| Nov 25, 2026 | 316 |
| Nov 24, 2026 | 324 |
| Nov 23, 2026 | 338 |
| Nov 22, 2026 | 301 |
| Nov 21, 2026 | 279 |
| Nov 20, 2026 | 99 |
| Nov 19, 2026 | 105 |
| Nov 18, 2026 | 93 |
| Nov 17, 2026 | 90 |
| Nov 16, 2026 | 78 |
| Nov 15, 2026 | 87 |
| Nov 14, 2026 | 84 |
| Nov 13, 2026 | 96 |
| Nov 12, 2026 | 135 |
| Nov 11, 2026 | 250 |
| Nov 10, 2026 | 254 |
| Nov 9, 2026 | 248 |
| Nov 8, 2026 | 237 |
| Nov 7, 2026 | 243 |
| Nov 6, 2026 | 227 |
| Nov 5, 2026 | 182 |
| Nov 4, 2026 | 59 |
| Nov 3, 2026 | 52 |
| Nov 2, 2026 | 58 |
| Nov 1, 2026 | 57 |
| Oct 31, 2026 | 81 |
| Oct 30, 2026 | 83 |
| Oct 29, 2026 | 70 |
| Oct 28, 2026 | 67 |
| Oct 27, 2026 | 68 |
| Oct 26, 2026 | 63 |
| Oct 25, 2026 | 60 |
| Oct 24, 2026 | 33 |
| Oct 23, 2026 | 27 |
| Oct 22, 2026 | 40 |
| Oct 21, 2026 | 61 |
| Oct 20, 2026 | 62 |
| Oct 19, 2026 | 61 |
| Oct 18, 2026 | 106 |
| Oct 17, 2026 | 188 |
| Oct 16, 2026 | 199 |
| Oct 15, 2026 | 193 |
| Oct 14, 2026 | 181 |
| Oct 13, 2026 | 182 |
| Oct 12, 2026 | 184 |
| Oct 11, 2026 | 143 |
| Oct 10, 2026 | 60 |
| Oct 9, 2026 | 60 |
| Oct 8, 2026 | 75 |
| Oct 7, 2026 | 238 |
| Oct 6, 2026 | 232 |
| Oct 5, 2026 | 232 |
| Oct 4, 2026 | 231 |
| Oct 3, 2026 | 222 |
| Oct 2, 2026 | 221 |
| Oct 1, 2026 | 203 |
| Sep 30, 2026 | 43 |
| Sep 29, 2026 | 42 |
| Sep 28, 2026 | 40 |
| Sep 27, 2026 | 43 |
| Sep 26, 2026 | 50 |
| Sep 25, 2026 | 43 |
| Sep 24, 2026 | 47 |
| Sep 23, 2026 | 59 |
| Sep 22, 2026 | 209 |
| Sep 21, 2026 | 209 |
| Sep 20, 2026 | 202 |
| Sep 19, 2026 | 192 |
| Sep 18, 2026 | 191 |
| Sep 17, 2026 | 188 |
| Sep 16, 2026 | 175 |
| Sep 15, 2026 | 26 |
| Sep 14, 2026 | 28 |
| Sep 13, 2026 | 35 |
| Sep 12, 2026 | 39 |
| Sep 11, 2026 | 40 |
| Sep 10, 2026 | 38 |
| Sep 9, 2026 | 30 |
| Sep 8, 2026 | 28 |
| Sep 7, 2026 | 27 |
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/1297786125-root)<a href="https://payloaddirectory.dev/plugins/1297786125-root"><img src="https://payloaddirectory.dev/badge/1297786125-root.svg" alt="Payload Directory"></a>README
See how your photo fits before you save it.
One photo might need to work in a wide hero, a square card, and a portrait mobile layout. Image Preview for Payload CMS lets editors check those formats side by side, adjust the crop or focal point, and watch every preview update as they edit.
payload-plugin-aspect-preview is a Payload CMS plugin for image cropping, focal point editing, and responsive image previews. It adds a live aspect ratio preview grid to upload collections, so editors can check several image formats on one screen in the Payload admin.

Install the plugin · Configure your website's image formats
A photo can look great in the media library and lose its subject when it fills a different shape on the website. Editors need to see what stays in the frame while they choose the image's crop and focal point.
Developers add the plugin to their upload collections and configure the ratios used by their frontend. Editors get the previews directly in Payload. Six common ratios are included to get started: square, 4:3, 3:2, 16:9, portrait 9:16, and a 1200 × 630 social share format.
pnpm add payload-plugin-aspect-preview
import { buildConfig } from 'payload'
import { aspectPreviewPlugin } from 'payload-plugin-aspect-preview'
export default buildConfig({
// ...
plugins: [
aspectPreviewPlugin({ collections: ['media'] }),
],
})
Your media collection must have uploads enabled. To use Payload's image processing and persist focal points, configure sharp in your Payload config, keep focalPoint enabled, and define imageSizes or resizeOptions on the collection. See Payload's upload configuration.
Give each preview the name of the component where the image will appear. Set its proportions to match your frontend:
aspectPreviewPlugin({
collections: ['media'],
aspectRatios: [
{ name: 'Homepage hero', ratio: '21:9', width: 21, height: 9, source: 'css', usage: 'Wide banner at the top of the homepage' },
{ name: 'Product card', ratio: '1:1', width: 1, height: 1, source: 'css', usage: 'Square images in the product grid' },
{ name: 'Mobile feature', ratio: '9:16', width: 9, height: 16, source: 'css', usage: 'Portrait image in the mobile layout' },
],
})
The previews simulate image framing using cover sizing and focal positioning. Configure the ratios yourself and use the saved focal point in your frontend's image positioning. The plugin previews the image inside each shape; it does not render your website's components or detect their styles automatically.
If a component lays a title, price, or badges over the photo, editors can't see what that text will cover. Add overlays to a ratio and its preview shows those areas as bands along the frame's edges:
aspectPreviewPlugin({
collections: ['media'],
aspectRatios: [
{
name: 'Product card',
ratio: '4:3',
width: 4,
height: 3,
usage: 'Title and price over the bottom of the photo',
overlays: [
{ label: 'Badges', edge: 'top', min: 0.12 },
{ label: 'Title + price', edge: 'bottom', min: 0.22, max: 0.4 },
],
},
{
name: 'Hero',
ratio: '16:9',
width: 16,
height: 9,
overlays: [{ label: 'Headline', edge: 'left', min: 0.35, max: 0.5 }],
},
],
})

min is the share of the frame the component always covers. It is drawn as a solid band.max is the share it covers at worst, such as a title that wraps to three lines. The stretch from min to max is hatched and ends in a dashed line. Leave max out when the area has a fixed size.top, bottom) or width (left, right). Measure them on your component at the size editors care about most.The bands are fixed to the frame, so they stay in place while the image moves under them as you change the focal point or crop. They don't block the editor and follow Payload's light and dark themes. Ratios without overlays look exactly as before.
The plugin checks overlays when Payload loads its config. An invalid entry (an empty label, an unknown edge, a fraction outside 0–1, max below min, or an overlay that covers nothing) stops startup with an error that names the ratio and the overlay.
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
collections | string[] | yes | — | Upload collection slugs to enhance. |
aspectRatios | AspectRatioConfig[] | no | DEFAULT_ASPECT_RATIOS | Ratios shown in the preview grid. |
disabled | boolean | no | false | Keep the schema field but disable the upload override. |
AspectRatioConfig| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Display label (e.g. "Social Share"). |
ratio | string | yes | Display token (e.g. "16:9"). |
width | number | yes | Ratio numerator (or absolute px width). |
height | number | yes | Ratio denominator (or absolute px height). |
source | 'css' | 'crop' | no | Display badge describing the intended use. Does not change image processing. |
usage | string | no | Description shown in the card footer. |
category | string | no | Optional metadata label. Does not group cards in the current UI. |
overlays | AspectRatioOverlay[] | no | Areas your frontend covers with text or UI, drawn over the preview. See Show where your site puts text over the image. |
AspectRatioOverlay| Field | Type | Required | Description |
|---|---|---|---|
label | string | yes | Shown inside the band (e.g. "Title + price"). |
edge | 'top' | 'bottom' | 'left' | 'right' | yes | The frame edge the covered area starts from. |
min | number | yes | Fraction (0–1) of the frame always covered. Height for top/bottom, width for left/right. |
max | number | no | Fraction (0–1, at least min) covered at worst. Defaults to min. |
Multiple collections
aspectPreviewPlugin({ collections: ['media', 'avatars'] })
Disable without dropping the schema
aspectPreviewPlugin({ collections: ['media'], disabled: true })
The same editor ships as a plain React component under payload-plugin-aspect-preview/playground. Nothing reachable from that entry imports payload or @payloadcms/*, so it runs on any React 19 page: a demo, a docs site, a tool of your own. Payload and @payloadcms/ui are optional peer dependencies, so installing the package without them is fine.
pnpm add payload-plugin-aspect-preview
It is a client component. In the Next.js App Router, render it from a file that starts with 'use client':
'use client'
import { useState } from 'react'
import {
AspectPreviewEditor,
type AspectPreviewValue,
} from 'payload-plugin-aspect-preview/playground'
export function ImageDemo() {
const [src, setSrc] = useState('/sample.jpg')
const [value, setValue] = useState<AspectPreviewValue>({ focal: { x: 50, y: 50 } })
return (
<>
{/* A picked file stays in the browser: it is shown through a blob: URL. */}
<input
type="file"
accept="image/*"
onChange={(e) => {
const file = e.target.files?.[0]
if (file) setSrc(URL.createObjectURL(file))
}}
/>
<AspectPreviewEditor src={src} value={value} onChange={setValue} />
</>
)
}
Revoke old blob: URLs with URL.revokeObjectURL once you replace them. The component imports its own stylesheets (the editor's and react-image-crop's), which the App Router accepts from any component.
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | — | The image: any URL the browser can load, blob: URLs included. Without it the editor shows emptyMessage. |
aspectRatios | AspectRatioConfig[] | DEFAULT_ASPECT_RATIOS | Ratios in the preview grid, overlays included. |
value | AspectPreviewValue | — | Controlled value: { crop?, focal }. |
defaultValue | AspectPreviewValue | no crop, focal at the centre | Starting value when you leave out value. |
onChange | (value, { reason }) => void | — | The whole next value. reason is 'user', or 'normalize' when the editor only converted a legacy pixel crop to percent. |
alt | string | 'Edit' | Alt text for the editable image. |
className, style | — | Added to the root element (.focal-editor). | |
emptyMessage | ReactNode | 'Upload an image…' | Shown while src is empty. |
value.crop is a percent rectangle over the whole image, or undefined for no crop. value.focal is a 0–100 position inside the crop (inside the whole image when there is none), the same space Payload stores focalX and focalY in. To place something on the whole image, convert it with toFullImageFocal(value.focal, value.crop) (pass { x: 0, y: 0, width: 100, height: 100 } when there is no crop). The entry also exports AspectRatioPreviewGrid, DEFAULT_ASPECT_RATIOS, toCropRelativeFocal, isRealCrop and the types.
Theming. Outside the Payload admin the editor falls back to a light, neutral palette. Override any --apv-* variable on your own class to match your site:
.my-demo.focal-editor {
--apv-bg: #0f1115;
--apv-bg-subtle: #171a21;
--apv-bg-muted: #1f232c;
--apv-border: #2a2f3a;
--apv-text: #e8eaee;
--apv-text-muted: #9aa1ad;
--apv-bg-inverse: #e8eaee;
--apv-on-inverse: #0f1115;
}
The full list is at the top of src/styles.css. The root also has margin-top: 20px, which you can reset the same way.
The plugin replaces the configured collections' upload UI with CustomUpload and adds an aspectPreview UI field rendered by FocalPointEditor, a thin Payload wrapper around AspectPreviewEditor. Crop and focal point edits flow through Payload's upload-edits context. Payload applies the crop on save and persists focal coordinates as focalX and focalY.
The preview grid uses cover sizing equivalent to object-fit: cover and object-position based on the focal point. When a crop is active, the grid previews that crop region with the focal point measured relative to it.
payload-plugin-aspect-preview adds live previews of multiple aspect ratios to Payload upload collections. Use it when one image needs to fit several formats, such as hero banners, product cards, thumbnails, and portrait mobile images. Configure aspectPreviewPlugin with your collection slugs and the ratios your frontend uses.
Payload already supports image cropping, focal points, and generated image size previews. This plugin brings crop and focal point editing together with a preview grid that updates as you edit. Its preview ratios can represent your frontend's image containers, even when you do not generate separate files for those ratios.
No. The grid shows how one shared crop and focal point fit different aspect ratios. Adding a preview does not create a new image size. Configure generated image sizes through Payload's imageSizes option.
It previews image framing inside the media editor. Use Payload's page live preview for the rest of your layout, text, and components.
They model cover sizing with focal positioning at your configured aspect ratios. Your frontend must use the corresponding ratios and saved focal coordinates. Different fit modes, additional crops, or image processing can change the result. Text your components place over the image is shown only where you describe it with overlays.
@payloadcms/ui ^3.85.0 (not needed for /playground)^19.0.0>=20.9.0The replacement upload UI uses @payloadcms/ui internals (FileDetails, Dropzone, PreviewSizes, …). These are not a stable public API, so a Payload minor upgrade may require a plugin update. Pin your Payload version and test after upgrades.
MIT © Sebastian Kolbusz
Topics
image framing
Non-destructive crop and focus areas for Payload uploads, with per-usage overrides and responsive framing
6080/wk2v3
payloadcms plugin image optimizer
Client-side resize, ThumbHash blur placeholders, filename strategies and bulk regeneration on top of Payload's sharp…
79666/wk27v3
images
On-demand Sharp image transforms with focal-point cropping, built-in LQIP placeholders and a favicons collection
6032/wk37v3
blur data urls
Generate blur placeholder data URLs automatically for images uploaded to Payload media collections
66139/wk84v3
payload blurhash
Generates a tiny base64 WebP blur placeholder automatically for image uploads in Payload collections
568/wk3v3
payload images
On-demand Sharp image transforms with focal-point cropping, placeholders and a responsive image component
5449/wk18v3