Search...
getGallery( )
Developer Preview
Gets a gallery by ID.
Description
The getGallery()
function returns a Promise that resolves to a gallery whose ID matches the given ID.
Syntax
function getGallery(galleryId: string, options: GetGalleryOptions): Promise<Gallery>
getGallery Parameters
NAME
TYPE
DESCRIPTION
galleryId
string
Gallery ID.
options
Optional
GetGalleryOptions
Options to use when getting the gallery.
Returns
Returned gallery.
Return Type:
Promise<
Gallery
>NAME
TYPE
DESCRIPTION
_createdDate
Date
Date and time the gallery was created.
_id
string
Gallery ID.
items
Array<
Item
>Media items in the gallery.
name
string
Gallery name.
sortOrder
number
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.
totalItems
number
Total number of items in the gallery.
Was this helpful?
Get an existing gallery
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23// Sample galleryId value: 'f18209c2-2ed5-4cbb-9cfd-45a3e6f93dbc'45export async function myGetGalleryFunction(galleryId) {6 try {7 const gallery = await proGallery.getGallery(galleryId);89 const id = gallery._id;10 const name = gallery.name;11 const items = gallery.items;12 const firstItemTitle = gallery.items[0].title;1314 console.log('Success! Got the gallery:', gallery);15 return gallery;16 } catch (error) {17 console.error(error);18 // Handle the error19 }20}2122/* Promise resolves to:23 * {24 * "_createdDate": "Mon Feb 08 2021 13:44:37",25 * "_id":"10874ccf-5867-4225-9550-3885079bad66",26 * "items": [27 * {28 * "_createdDate": Tue Mar 30 2021 15:23:22,29 * "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",30 * "_updatedDate": Tue Mar 30 2021 15:23:22,31 * "description": "This is the first item in my gallery.",32 * "sortOrder": 1657439075188,33 * "title": "Item 1",34 * "type": "VIDEO",35 * "video": {36 * "type": 'VIMEO',37 * "videoInfo": 'https://vimeo.com/322240916',38 * "duration": 500039 * }40 * },41 * {42 * "_createdDate": Sun Jul 03 2022 12:05:15,43 * "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",44 * "_updatedDate": Tues Jul 05 2022 10:25:45,45 * "description": "This is the second item in my gallery.",46 * "sortOrder": 1857439076299,47 * "title": "Item 2",48 * "type": "IMAGE",49 * "image": {50 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"51 * }52 * }53 * ],54 * "name": "My New Gallery",55 * "sortOrder": "1098567432145",56 * "totalItems": 257 * }58 */
Get an existing gallery with additional options
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23/* Sample galleryId value: 'f18209c2-2ed5-4cbb-9cfd-45a3e6f93dbc'4 *5 * Sample options value:6 * {7 * itemLimit: 2,8 * itemOffset: 19 * }10 */1112export async function myGetGalleryFunction(galleryId, options) {13 try {14 const gallery = await proGallery.getGallery(galleryId, {options});1516 const id = gallery._id;17 const name = gallery.name;18 const items = gallery.items;19 const firstItemTitle = gallery.items[0].title;2021 console.log('Success! Got the gallery:', gallery);22 return gallery;23 } catch (error) {24 console.error(error);25 // Handle the error26 }27}2829/* Promise resolves to:30 * {31 * "_createdDate": "Mon Feb 08 2021 13:44:37",32 * "_id":"10874ccf-5867-4225-9550-3885079bad66",33 * "items": [34 * {35 * "_createdDate": Tue Mar 30 2021 15:23:22,36 * "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",37 * "_updatedDate": Tue Mar 30 2021 15:23:22,38 * "description": "This is the first item in my gallery.",39 * "sortOrder": 165743907518840 * "title": "Item 1"41 * "type": "IMAGE",42 * "image": {43 * "imageInfo": "wix:image://v1/38939f9568z222d6avc6285c9ac1e9129.jpg/38939f9568z222d6avc6285c9ac1e9129.jpg#originWidth=200&originHeight=199"44 * }45 * },46 * {47 * "_createdDate": Sun Jul 03 2022 12:05:15,48 * "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",49 * "_updatedDate": Tues Jul 05 2022 10:25:4550 * "description": "This is the second item in my gallery.",51 * "sortOrder": 185743907629952 * "title": "Item 2"53 * "type": "IMAGE",54 * "image": {55 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"56 * }57 * }58 * ],59 * "name": "My New Gallery",60 * "sortOrder": "1098567432145",61 * "totalItems": 262 * }63 */