Adds media items to a specified product, either via URL or existing media ID.
NOTE: The URL is not validated and no event is triggered to indicate if the media was added successfully.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function addProductMedia(
_id: string,
media: Array<MediaDataForWrite>,
): Promise<void>;
Product ID.
Sources of media items already uploaded to the Wix site.
import { products } from "wix-stores.v2";
async function addProductMedia(id, media) {
try {
const result = await products.addProductMedia(id, media);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.