Components / cms-media-picker
Media picker
The dialog that chooses a file from the media library (search, type tabs, folders, upload), the upload logic (straight to the storage, parts for large files, retry of what is missing, browser-made thumbnails) and the tiles and upload panel shared with the media library.
With the shadcn CLI
npx shadcn add https://agent-cms-docs.vercel.app/r/cms-media-picker.jsonWith the agent-cms CLI
npx @mainsoft/agent-cms add cms-media-pickerThis dialog opens from the editor. In the editor demo, press "Insert media" above the markdown. Open the editor demo
Usage#
The editor and the field form use it already. In your own form:
<CmsMediaPicker
open={open}
onOpenChange={setOpen}
kinds={["image"]}
accept={["image/png", "image/jpeg"]}
onPick={(asset) => setCover(asset.id)}
/>kinds limits what can be chosen, accept narrows what the upload button offers, store shows one store only. onPick gets the file with its id, name, kind and addresses; a body takes .
It comes with cms-doc-editor: npx @mainsoft/agent-cms add cms-doc-editor brings it, also in apps without a media library (the button stays hidden there).