Subchapter 1.108
references/dashboard-page/DASHBOARD_API_MEDIA_AND_PLUGINS.mdMarkdown6 KBView on GitHub
Host Module ‘@wix/dashboard’ ‘openMediaManager()’ opens the Wix Media Manager in a modal to let users pick media files. Developer Preview.
Method parameters:
options?: Options — Optional Media Manager optionsOptions:
category (string, optional): Media type to display. Supported: “IMAGE”, “VIDEO”, “MUSIC”, “DOCUMENT”, “VECTOR_ART”, “3D_IMAGE”. Default: all except “3D_IMAGE”multiSelect (boolean, optional): Whether multiple files can be selected. Default: falseReturns:
The published SDK reference (opens in a new tab)
declares Promise<{ items: Array<FileDescriptor> }>.
At the host boundary, handle the result defensively as
{ items: Array<FileDescriptor> } | null | undefined. Treat a missing result or empty items
as dismissal and leave the draft unchanged. This guard is defensive handling, not a verified
claim about the SDK’s cancellation return value.
File descriptor: FileDescriptor is the full schema describing a Media Manager file, including IDs, timestamps, media-type, URLs, status, labels, and a media-specific payload.
Typical fields:
_id (string): File GUID_createdDate (Date): Creation time_updatedDate (Date): Last update timedisplayName (string): File name as shown in Media ManagermediaType (ARCHIVE | AUDIO | DOCUMENT | IMAGE | MODEL3D | OTHER | UNKNOWN | VECTOR | VIDEO): Media file typeurl (string, optional): Static URL of the file when populatedthumbnailUrl (string): Thumbnail URLsizeInBytes (string): File size in bytesparentFolderId (string): ID of the file’s parent folder.siteId (string): Site GUID where the media is storedprivate (boolean): Whether file is privateoperationStatus (FAILED | READY | PENDING): Upload/processing statusstate (DELETED | OK): File statehash (string): File hashlabels (string[]): User/AI labelssourceUrl (string): URL where the file was uploaded from.media (object): One of the following variants with specific fields
Image selection:
Read the documented nested image URI from media.image.image, with url as a fallback.
The string branch below defensively accepts an adapter returning a direct image value;
it is not an additional guarantee of the published SDK contract. Check the installed host
callback’s types when integrating a different adapter.
import { dashboard } from '@wix/dashboard';
export async function pickImage() {
const selection = await dashboard.openMediaManager({
category: 'IMAGE',
multiSelect: false,
});
const file = selection?.items?.[0];
if (!file) return undefined;
const image: unknown = file.media?.image;
const nested = image && typeof image === 'object' && 'image' in image
? image.image
: undefined;
const source = typeof image === 'string' ? image
: typeof nested === 'string' ? nested : file.url;
return source ? { file, source } : undefined;
}Keep file for its identity and metadata and source for the image value. Update the draft
only when this helper returns a selection. The entity save lifecycle is in
IMAGE_EDITING.md.
Host Module ‘@wix/dashboard’ ‘addSitePlugin()’ adds a site plugin to one of the slots supported in an app created by Wix. You can target a specific slot or rely on prioritized slots configured in your app’s dashboard.
Notes:
Method parameters:
pluginId: string — ID of your site plugin (from the extension’s settings in your app’s dashboard)options: addSitePluginOptions — Options for adding the site pluginAdd site plugin options:
placement?: PluginPlacement — Details of the slot to add the plugin to. If omitted, the plugin is added to the first available slot based on your installation settings. If all prioritized slots are occupied, it won’t be addedPlugin placement:
appDefinitionId: string — ID of the Wix app hosting the widget and slot (see list of apps created by Wix)widgetId: string — ID of the host widget in which the slot existsslotId: string — ID of the slot in the host widgetReturns:
Resolves on success. See Errors for possible rejection reasons
Promise<void>
Errors:
Example:
import { dashboard } from '@wix/dashboard';
// Add a site plugin to a specific slot
const pluginId = "975bffb7-3c04-42cc-9840-3d48c24e73d5";
const pluginPlacement = {
appDefinitionId: "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
widgetId: "a91a0543-d4bd-4e6b-b315-9410aa27bcde",
slotId: "slot1",
};
dashboard
.addSitePlugin(pluginId, { placement: pluginPlacement })
.then(() => {
console.log("Plugin added successfully");
})
.catch((error) => {
console.error("Error adding plugin:", error);
});
// Add a site plugin without specifying a slot (uses prioritized slots)
const pluginId = "975bffb7-3c04-42cc-9840-3d48c24e73d5";
dashboard
.addSitePlugin(pluginId, {})
.then(() => {
console.log("Plugin added successfully");
})
.catch((error) => {
console.error("Error adding plugin:", error);
});