Setup
createCropImage
If your media collection uses a non-default slug (e.g. files instead of media), use createCropImage so the plugin and fields always target the same collection.
- 1
Create plugin + field factory once
typescriptimport { createCropImage } from 'payload-plugin-image-cropper' const { plugin, field } = createCropImage({ mediaCollectionSlug: 'files', mediaDir: path.join(process.cwd(), 'public/files'), }) - 2
Register the plugin
typescriptplugins: [plugin] - 3
Use field() in collections
typescriptfield({ name: 'heroImage', label: 'Hero Image', crops: [/* ... */], })
This avoids setting mediaCollectionSlug in two places — a mismatch causes silent 404s at crop generation time.