updateGallery( )
Updates a gallery.
Description
The updateGallery()
function returns a Promise that resolves to an updated gallery. Only the fields in the gallery
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 updateGallery(_id: string, gallery: UpdateGallery): Promise<Gallery>
updateGallery Parameters
NAME
TYPE
DESCRIPTION
ID of the gallery to update.
The information for the gallery being updated.
Returns
Updated gallery.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the gallery was created.
Gallery ID.
Media items in the gallery.
Gallery name.
Index that determines which position a gallery is displayed on the site.
Note: If you assign the same sort order index to more than one gallery, the function fails.
Total number of items in the gallery.
Was this helpful?
Update a gallery
1import { proGallery } from 'wix-pro-gallery-backend';23/* Sample _id value: '10874ccf-5867-4225-9550-3885079bad66'4 *5 * Sample gallery value:6 * {7 * "name": "New Name",8 * "sortOrder": 4209 * }10 */11export async function myUpdateGalleryFunction(_id, gallery) {12 try {13 const updatedGallery = await proGallery.updateGallery(_id, gallery);1415 const name = updatedGallery.name;16 const sortOrder = updatedGallery.sortOrder;1718 console.log('Success! Updated the gallery:', updatedGallery);19 return updatedGallery;20 } catch (error) {21 console.error(error);22 // Handle the error23 }24}2526/* Promise resolves to:27 * {28 * "_createdDate": "Mon Feb 08 2021 13:44:37",29 * "_id":"10874ccf-5867-4225-9550-3885079bad66",30 * "items": [31 * {32 * "_createdDate": Tue Mar 30 2021 15:23:22,33 * "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",34 * "_updatedDate": Tue Mar 30 2021 15:23:22,35 * "description": "This is the first item in my gallery.",36 * "sortOrder": 165743907518837 * "title": "Item 1"38 * "type": "IMAGE",39 * "image": {40 * "imageInfo": "wix:image://v1/38939f9568z222d6avc6285c9ac1e9129.jpg/38939f9568z222d6avc6285c9ac1e9129.jpg#originWidth=200&originHeight=199"41 * }42 * },43 * {44 * "_createdDate": Sun Jul 03 2022 12:05:15,45 * "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",46 * "_updatedDate": Tues Jul 05 2022 10:25:4547 * "description": "This is the second item in my gallery.",48 * "sortOrder": 185743907629949 * "title": "Item 2"50 * "type": "IMAGE",51 * "image": {52 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"53 * }54 * }55 * ],56 * "name": "New Name",57 * "sortOrder": "420",58 * "totalItems": 259 * }60 */61