This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a list of media items in a specified gallery.
This function retrieves a list of up to 100 gallery items. The gallery items are listed by sortOrder
in descending order.
function listGalleryItems(
galleryId: string,
options: ListGalleryItemsOptions,
): Promise<ListGalleryItemsResponse>;
Gallery ID.
Options to use when getting the list of gallery items.
import { proGallery } from "wix-pro-gallery-backend";
// Sample galleryId value: 'f18209c2-2ed5-4cbb-9cfd-45a3e6f93dbc'
export async function myListGalleryItemsFunction(galleryId) {
try {
const galleryItems = await proGallery.listGalleryItems(galleryId);
const firstGalleryItemId = galleryItems[0]._id;
const secondGalleryItemName = galleryItems[1].title;
console.log("Success! Got a list of gallery items:", galleryItems);
return galleryItems;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "items": [
* {
* "_createdDate": Tue Mar 30 2021 15:23:22,
* "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",
* "_updatedDate": Tue Mar 30 2021 15:23:22,
* "description": "This is the first item in my gallery.",
* "sortOrder": 1657439075188,
* "link": {
* "text": 'Click here for more info.',
* "url": 'https://www.wix.com/about/us'
* },
* "title": "Item 1",
* "type": "TEXT",
* "text": {
* "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>",
* "css": {
* "backgroundColor": "rgba(232, 230, 230, 0.7)",
* "googleFonts": [],
* "height": 420,
* "textVerticalAlignment": "middle",
* "canvasLayout": "square",
* "ratio": -50,
* "padding": 30,
* "width": 420
* }
* }
* },
* {
* "_createdDate": Sun Jul 03 2022 12:05:15,
* "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",
* "_updatedDate": Tues Jul 05 2022 10:25:45,
* "description": "This is the second item in my gallery.",
* "sortOrder": 1857439076299,
* "title": "Item 2",
* "type": "IMAGE",
* "image": {
* "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"
* }
* },
* {
* "_createdDate": Tues Jul 05 2022 08:02:37,
* "_id": "2297a07b-ab93-4326-a222-6d0bd8da0625",
* "_updatedDate": Tues Jul 05 2022 10:25:45,
* "description": "This is the second item in my gallery.",
* "sortOrder": 1857439076299,
* "title": "My only item",
* "type": "IMAGE",
* "image": {
* "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"
* }
* }
* ]
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.