Search.../

updateGalleryItem( )

Developer Preview

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 the imageInfo parameter currently only supports the Wix media URL.

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
identifiers
UpdateGalleryItemIdentifiers

Gallery ID and Item ID.

item
UpdateGalleryItem

The information for the gallery item being updated.

Returns

Updated media item.

Return Type:

Promise<
Item
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the item was created.

_id
string

Item ID.

_updatedDate
Date

Date and time the item was last updated.

description
string

Item description.

image
Image

Details about the image.

link
Link

Link from the item. You can link to Wix sites or external URLs.

sortOrder
number

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.

tags
Tags

Item tags.

text
Text

Details about the text file.

title
string

Item title.

type
string

Supported values:

  • 'IMAGE'
  • 'TEXT'
  • 'UNDEFINED'
  • 'VIDEO'
video
Video

Details about the video.

Was this helpful?

Update a gallery item

Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';
2
3/* 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 */
9
10export async function myUpdateGalleryItemFunction() {
11 try {
12 const updatedGalleryItem = await proGallery.updateGalleryItem({galleryId, itemId}, {title});
13
14 const title = updatedGalleryItem.title;
15
16 console.log('Success! Updated the gallery item:', updatedGalleryItem);
17 return updatedGalleryItem;
18 } catch (error) {
19 console.error(error);
20 // Handle the error
21 }
22}
23
24/* 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": 2000
37 * }
38 * }
39 */