Search.../

removeProductMedia( )

Removes specified media items from a product. Pass an empty array to remove all media items.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function removeProductMedia(_id: string, mediaIds: Array<string>): Promise<void>

removeProductMedia Parameters

NAME
TYPE
DESCRIPTION
_id
string

Product ID.

mediaIds
Array<
string
>

List of media IDs to remove. Pass an empty array to delete all media items for the product.

Returns

Return Type:

Promise<
void
>

Was this helpful?

removeProductMedia example

Copy Code
1import { products } from 'wix-stores.v2';
2
3 async function removeProductMedia(id, mediaIds) {
4 try {
5 const result = await products.removeProductMedia(id, mediaIds);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13