Image Modal
ImageModal provides an upload interface and preview for entity image fields. Supports drag-and-drop, cropping, and aspect ratio constraints.
Import
import { ImageModal } from "@phpcreation/frontend-crud-react-nextjs-bundle/components/ImageModal";Usage
import { ImageModal } from "...";
<ImageModal
open={imageOpen}
onOpenChange={setImageOpen}
uploadUrl={`/api/entities/${entity.id}/image`}
currentImageUrl={entity.imageUrl}
aspectRatio={16 / 9}
onSuccess={(imageUrl) => {
setImageOpen(false);
refresh();
}}
/>Props
| Prop | Type | Description |
|---|---|---|
open | boolean | Modal open state |
onOpenChange | (open: boolean) => void | Open state handler |
uploadUrl | string | API endpoint for image upload |
currentImageUrl | string | Current image URL (for preview) |
aspectRatio | number | Crop aspect ratio (e.g., 16/9, 1) |
onSuccess | (url: string) => void | Called with the new image URL |
Related
Last updated on