This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a media item in a specified gallery.
Only the fields in the item
object parameter can be updated. Specify which fields to update. Unspecified fields remain the same.
Important:
When updating image
items in your gallery, the images must be uploaded to the Wix Media Manager first as the imageInfo
parameter currently only supports the Wix media URL.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateGalleryItem(
identifiers: UpdateGalleryItemIdentifiers,
item: UpdateGalleryItem,
options: UpdateGalleryItemOptions,
): Promise<Item>;
Gallery ID and Item ID.
The information for the gallery item being updated.
import { proGallery } from "wix-pro-gallery-backend";
/* Sample galleryId value: 'af5c3670-9b0f-4d86-b3b9-19fe62006c39'
*
* Sample itemId value: '813def66-0f0b-40b7-a9df-c731345a926f'
*
* Sample title value: 'My Updated Item Title'
*/
export async function myUpdateGalleryItemFunction() {
try {
const updatedGalleryItem = await proGallery.updateGalleryItem(
{ galleryId, itemId },
{ title },
);
const title = updatedGalleryItem.title;
console.log("Success! Updated the gallery item:", updatedGalleryItem);
return updatedGalleryItem;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "Mon Feb 20 2021 15:22:15",
* "_id": "813def66-0f0b-40b7-a9df-c731345a926f",
* "_updatedDate": Tue Mar 30 2021 15:23:22,
* "description": "This is the first item in my gallery.",
* "sortOrder": 1657439075188,
* "title": "My Updated Item Title",
* "type": 'VIDEO',
* "video": {
* "type": 'YOUTUBE',
* "videoInfo": 'https://www.youtube.com/results?search_query=uplifting+upbeat+music',
* "duration": 2000
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.