Search...
addProductMedia( )
Adds media items to a specified product, either via URL or existing media ID.
Description
NOTE: The URL is not validated and no event is triggered to indicate if the media was added successfully.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function addProductMedia(_id: string, media: Array<MediaDataForWrite>): Promise<void>
addProductMedia Parameters
NAME
TYPE
DESCRIPTION
_id
string
Product ID.
media
Array<
MediaDataForWrite
>Sources of media items already uploaded to the Wix site.
Returns
Return Type:
Promise<
void
>Was this helpful?
addProductMedia example
Copy Code
1import { products } from 'wix-stores.v2';23 async function addProductMedia(id, media) {4 try {5 const result = await products.addProductMedia(id, media);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13