Important:
This API is in Developer Preview and is subject to change.
Opens the Wix Media Manager in a modal.
This function can only be used in page code files for dashboard pages created in the Wix editor or with Wix Blocks.
The Media Manager allows a site contributor to select one or more of the site's media files.
The openMediaManager()
function returns a promise that resolves to an object containing an array of file descriptors for the selected media files.
function openMediaManager(
options: OpenMediaManagerOptions,
): Promise<openMediaManagerReturn>;
Options for the Media Manager.
import { openMediaManager } from "wix-dashboard";
/* Sample options value:
* {
* multiSelect: true,
* category: 'IMAGE'
* }
*/
openMediaManager(options)
.then((fileDescriptors) => {
const firstId = fileDescriptors.items[0]._id;
const firstDisplayname = fileDescriptors.items[0].displayName;
console.log("Success! Retrieved these fileDescriptors:", fileDescriptors);
return fileDescriptors;
})
.catch((error) => {
console.error(error);
// Handle the error
});
/* Promise resolves to:
* [
* {
* "_createdDate": "2023-07-23T10:33:00.000Z",
* "_id": "w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
* "_updatedDate": "2023-07-23T10:33:00.000Z",
* "displayName": "example.jpg",
* "hash": "x5bq2o4p8fj68xqt25v49wdnasys04xe",
* "labels": [],
* "media": {
* "image": {
* "faces": [],
* "image": "wix:image://v1/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg/example.jpg"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "47177",
* "sourceUrl": "https://example.org/filename.jpg",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg"
* }
* ...
* ]
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.