> Portal Navigation:
>
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt
# Method name: listGalleryItems(galleryId: string, options: ListGalleryItemsOptions)
# Method package: wixProGalleryBackend
# Method menu location: wixProGalleryBackend --> proGallery --> listGalleryItems
# Method Link: https://dev.wix.com/docs/velo/apis/wix-pro-gallery-backend/pro-gallery/list-gallery-items.md
# Method Description:
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.
# Method Code Examples:
*** Note: do not assume any prop names or enum values other than the ones in the example.
## List gallery items
```javascript
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
",
* "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"
* }
* }
* ]
* }
*/
```
## List gallery items with additional options
```javascript
import { proGallery } from 'wix-pro-gallery-backend';
/* Sample galleryId value: 'f18209c2-2ed5-4cbb-9cfd-45a3e6f93dbc'
* Sample itemLimit value: 1
* Sample itemOffset value: 10
*/
export async function myListGalleryItemsFunction(galleryId, itemLimit, itemOffset) {
try {
const galleryItems = await proGallery.listGalleryItems(galleryId, {itemLimit, itemOffset});
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": 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": "11th Item",
* "link": {
* "text": 'Click here for more info.',
* "url": 'https://www.wix.com/about/us'
* },
* "type": "IMAGE",
* "image": {
* "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"
* }
* ]
* }
*/
```
---