updateGalleryItem( )
Updates a media item in a specified gallery.
Description
The updateGalleryItem()
function returns a Promise that resolves to an updated gallery item. 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 theimageInfo
parameter currently only supports the Wix media URL.
Override permissions
This function is restricted and only runs if you elevate permissions using the wix-auth
elevate()
function.
Warning: Elevating a function allows it to be called by any site visitor. Exercise caution to prevent security vulnerabilities.
Syntax
function updateGalleryItem(identifiers: UpdateGalleryItemIdentifiers, item: UpdateGalleryItem): Promise<Item>
updateGalleryItem Parameters
NAME
TYPE
DESCRIPTION
Gallery ID and Item ID.
The information for the gallery item being updated.
Returns
Updated media item.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the item was created.
Item ID.
Date and time the item was last updated.
Item description.
Details about the image.
Link from the item. You can link to Wix sites or external URLs.
Index that determines which position a media item is displayed in the gallery.
Default: Epoch timestamp.
Note: If you assign the same sort order index to more than one media item in a gallery, the function fails.
Item tags.
Details about the text file.
Item title.
Supported values:
'IMAGE'
'TEXT'
'UNDEFINED'
'VIDEO'
Details about the video.
Was this helpful?
Update a gallery item
1import { proGallery } from 'wix-pro-gallery-backend';23/* Sample galleryId value: 'af5c3670-9b0f-4d86-b3b9-19fe62006c39'4 *5 * Sample itemId value: '813def66-0f0b-40b7-a9df-c731345a926f'6 *7 * Sample title value: 'My Updated Item Title'8 */910export async function myUpdateGalleryItemFunction() {11 try {12 const updatedGalleryItem = await proGallery.updateGalleryItem({galleryId, itemId}, {title});1314 const title = updatedGalleryItem.title;1516 console.log('Success! Updated the gallery item:', updatedGalleryItem);17 return updatedGalleryItem;18 } catch (error) {19 console.error(error);20 // Handle the error21 }22}2324/* Promise resolves to:25 * {26 * "_createdDate": "Mon Feb 20 2021 15:22:15",27 * "_id": "813def66-0f0b-40b7-a9df-c731345a926f",28 * "_updatedDate": Tue Mar 30 2021 15:23:22,29 * "description": "This is the first item in my gallery.",30 * "sortOrder": 1657439075188,31 * "title": "My Updated Item Title",32 * "type": 'VIDEO',33 * "video": {34 * "type": 'YOUTUBE',35 * "videoInfo": 'https://www.youtube.com/results?search_query=uplifting+upbeat+music',36 * "duration": 200037 * }38 * }39 */