npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

payload-plugin-aspect-preview

v0.2.1

Published

Single-screen crop, focal point, and live multi-aspect-ratio preview editor for Payload upload collections.

Readme

payload-plugin-aspect-preview

npm version license

Single-screen crop, focal point, and live multi-aspect-ratio preview for Payload upload collections. Replaces Payload's separate crop/focal drawers with one editor that shows, in real time, how your image will look at every aspect ratio your frontend uses.

edit_preview

Features

  • Crop, focal point, and preview on one screen — no drawer round-trips.
  • Live preview grid across any set of aspect ratios as you drag the focal point or draw a crop.
  • Zero-config defaults (six common ratios) — override with your own list.
  • Simulates the frontend's object-fit: cover + focal positioning so previews match production.

Requirements

  • Payload ^3.85.0
  • React ^19

Compatibility note: the replacement upload field builds on @payloadcms/ui internals (FileDetails, Dropzone, PreviewSizes, …). These are not a stable public API, so a Payload minor upgrade may occasionally require a plugin update. Pin your Payload version and test after upgrades.

Installation

pnpm add payload-plugin-aspect-preview

Quick start

import { aspectPreviewPlugin } from 'payload-plugin-aspect-preview'

export default buildConfig({
  // ...
  plugins: [
    aspectPreviewPlugin({ collections: ['media'] }), // uses built-in default ratios
  ],
})

Your media collection must be an upload collection (upload: { ... }), ideally with focalPoint: true.

Configuration

| 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 | Badge showing how the frontend renders it. Default 'css'. | | usage | string | no | Description shown in the card footer. | | category | string | no | Free-form grouping label. |

Examples

Custom aspect ratios

aspectPreviewPlugin({
  collections: ['media'],
  aspectRatios: [
    { name: 'Hero', ratio: '21:9', width: 21, height: 9, source: 'css', usage: 'Landing hero' },
    { name: 'Card', ratio: '1:1', width: 1, height: 1, source: 'crop', usage: 'Product cards' },
  ],
})

Multiple collections

aspectPreviewPlugin({ collections: ['media', 'avatars'] })

Disable without dropping the schema

aspectPreviewPlugin({ collections: ['media'], disabled: true })

How it works

The plugin wraps each upload collection with a custom admin UI component (CustomUpload). It injects a UI field (FocalPointEditor) that overlays the live preview grid, replacing Payload's default crop/adjust drawer. The grid simulates object-fit: cover with the focal point as the anchor, so you see exactly how each ratio will render on the frontend. Crop and focal coordinates are stored in the document's built-in focalPoint field (if present) and in-memory image crop state managed by react-image-crop.

License

MIT © Sebastian Kolbusz