> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # RemoveProductMedia # Package: catalogV1 # Namespace: CatalogWriteApi # Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/remove-product-media.md ## Permission Scopes: Manage Products: SCOPE.DC-STORES.MANAGE-PRODUCTS ## Introduction Removes specified media items from a product. Pass an empty array to remove all media items. --- ## REST API ### Schema ``` Method: removeProductMedia Description: Removes specified media items from a product. Pass an empty array to remove all media items. URL: https://www.wixapis.com/stores/v1/products/{id}/media/delete Method: POST Method parameters: param name: mediaIds | type: array | description: List of media GUIDs to remove. Pass an empty array to delete all media items for the product. Return type: RemoveProductMediaResponse EMPTY-OBJECT {} ``` ### Examples ### RemoveProductMedia ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/stores/v1/products/1044e7e4-37d1-0705-c5b3-623baae212fd/media/delete' \ --data-binary '{ "mediaIds": [ "mediaId1", "mediaId2" ] }' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.catalogV1.CatalogWriteApi.removeProductMedia(_id, mediaIds) Description: Removes specified media items from a product. Pass an empty array to remove all media items. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: _id, mediaIds Method parameters: param name: _id | type: string | description: Product GUID. | required: true param name: mediaIds | type: array | description: List of media GUIDs to remove. Pass an empty array to delete all media items for the product. | required: true Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### Remove all media items from a product ```javascript /************************************** * Backend code - products.web.js/ts * **************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { products } from '@wix/stores'; export const removeProductMedia = webMethod(Permissions.Anyone, (_id, mediaIds) => { return products.removeProductMedia(_id, mediaIds); }); /************* * Page code * *************/ import { items } from '@wix/data'; import { removeProductMedia } from 'backend/products.web'; // ... const productName = ...; // get name of product items.query("Stores/Products") .eq("name", productName) .find() .then((results) => { if (results.items.length > 0) { const _id = results.items[0]._id; removeProductMedia(_id, []) // passing an empty array to remove all media items .then(() => { // all media items removed from the product }) .catch((error) => { // media items not removed from the product }); } }); ``` ### removeProductMedia (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { products } from '@wix/stores'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { products }, // Include the auth strategy and host as relevant }); async function removeProductMedia(_id,mediaIds) { const response = await myWixClient.products.removeProductMedia(_id,mediaIds); }; ``` ---