Search...
listGalleryItems( )
Developer Preview
Retrieves a list of media items in a specified gallery.
Description
The listGalleryItems()
function returns a Promise that resolves to a list of up to 100 gallery items. The gallery items are listed by sortOrder
in descending order.
Syntax
function listGalleryItems(galleryId: string, options: ListGalleryItemsOptions): Promise<ListGalleryItemsResponse>
listGalleryItems Parameters
NAME
TYPE
DESCRIPTION
galleryId
string
Gallery ID.
options
Optional
ListGalleryItemsOptions
Options to use when getting the list of gallery items.
Returns
Return Type:
Promise<
ListGalleryItemsResponse
>NAME
TYPE
DESCRIPTION
items
Array<
Item
>List of media items in the gallery.
Was this helpful?
List gallery items
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23// Sample galleryId value: 'f18209c2-2ed5-4cbb-9cfd-45a3e6f93dbc'45export async function myListGalleryItemsFunction(galleryId) {6 try {7 const galleryItems = await proGallery.listGalleryItems(galleryId);89 const firstGalleryItemId = galleryItems[0]._id;10 const secondGalleryItemName = galleryItems[1].title;1112 console.log('Success! Got a list of gallery items:', galleryItems);13 return galleryItems;14 } catch (error) {15 console.error(error);16 // Handle the error17 }18}1920/* Promise resolves to:21 * {22 * "items": [23 * {24 * "_createdDate": Tue Mar 30 2021 15:23:22,25 * "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",26 * "_updatedDate": Tue Mar 30 2021 15:23:22,27 * "description": "This is the first item in my gallery.",28 * "sortOrder": 1657439075188,29 * "link": {30 * "text": 'Click here for more info.',31 * "url": 'https://www.wix.com/about/us'32 * },33 * "title": "Item 1",34 * "type": "TEXT",35 * "text": {36 * "html": "\n <div class=\"te-pro-gallery-text-item\"\n style=\"padding: 30px;\n width: 420px;\n height: 420px;\n background-color: rgba(232, 230, 230, 0.7);\n transform-style: preserve-3d;\n overflow: hidden;\n word-wrap: break-word;\n font-style: normal; font-weight:normal;\n \">\n <div style=\"\n position: relative;\n top: 50%;\n transform: translateY(-50%);\">\n <p style=\"text-align:center\"><span style=\"color:#d2f6de;\"><span style=\"font-size:50px\">woohoo</span></span></p>\n\n </div>\n </div>",37 * "css": {38 * "backgroundColor": "rgba(232, 230, 230, 0.7)",39 * "googleFonts": [],40 * "height": 420,41 * "textVerticalAlignment": "middle",42 * "canvasLayout": "square",43 * "ratio": -50,44 * "padding": 30,45 * "width": 42046 * }47 * }48 * },49 * {50 * "_createdDate": Sun Jul 03 2022 12:05:15,51 * "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",52 * "_updatedDate": Tues Jul 05 2022 10:25:45,53 * "description": "This is the second item in my gallery.",54 * "sortOrder": 1857439076299,55 * "title": "Item 2",56 * "type": "IMAGE",57 * "image": {58 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"59 * }60 * },61 * {62 * "_createdDate": Tues Jul 05 2022 08:02:37,63 * "_id": "2297a07b-ab93-4326-a222-6d0bd8da0625",64 * "_updatedDate": Tues Jul 05 2022 10:25:45,65 * "description": "This is the second item in my gallery.",66 * "sortOrder": 1857439076299,67 * "title": "My only item",68 * "type": "IMAGE",69 * "image": {70 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"71 * }72 * }73 * ]74 * }75 */
List gallery items with additional options
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23/* Sample galleryId value: 'f18209c2-2ed5-4cbb-9cfd-45a3e6f93dbc'4 * Sample itemLimit value: 15 * Sample itemOffset value: 106 */78export async function myListGalleryItemsFunction(galleryId, itemLimit, itemOffset) {9 try {10 const galleryItems = await proGallery.listGalleryItems(galleryId, {itemLimit, itemOffset});1112 const firstGalleryItemId = galleryItems[0]._id;13 const secondGalleryItemName = galleryItems[1].title;1415 console.log('Success! Got a list of gallery items:', galleryItems);16 return galleryItems;17 } catch (error) {18 console.error(error);19 // Handle the error20 }21}2223/* Promise resolves to:24 * {25 * "items": [26 * {27 * "_createdDate": Sun Jul 03 2022 12:05:15,28 * "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",29 * "_updatedDate": Tues Jul 05 2022 10:25:45,30 * "description": "This is the second item in my gallery.",31 * "sortOrder": 1857439076299,32 * "title": "11th Item",33 * "link": {34 * "text": 'Click here for more info.',35 * "url": 'https://www.wix.com/about/us'36 * },37 * "type": "IMAGE",38 * "image": {39 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"40 * }41 * ]42 * }43 */