Search...
getGalleryItem( )
Developer Preview
Gets a gallery item by ID.
Description
The getGalleryItem()
function returns a Promise that resolves to a media item in a specified gallery whose ID matches the given ID.
Syntax
function getGalleryItem(identifiers: GetGalleryItemIdentifiers): Promise<Item>
getGalleryItem Parameters
NAME
TYPE
DESCRIPTION
identifiers
GetGalleryItemIdentifiers
Gallery ID and Item ID.
Returns
Returned media item.
Return Type:
Promise<
Item
>NAME
TYPE
DESCRIPTION
_createdDate
Date
Date and time the item was created.
_id
string
Item ID.
_updatedDate
Date
Date and time the item was last updated.
description
string
Item description.
image
Image
Details about the image.
link
Link
Link from the item. You can link to Wix sites or external URLs.
sortOrder
number
Index that determines which position a media item is displayed in the gallery.
Default: Epoch timestamp.
Note: If you assign the same sort order index to more than one media item in a gallery, the function fails.
tags
Tags
Item tags.
text
Text
Details about the text file.
title
string
Item title.
type
string
Supported values:
'IMAGE'
'TEXT'
'UNDEFINED'
'VIDEO'
video
Video
Details about the video.
Was this helpful?
Get a gallery item by ID
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23/* Sample galleryId value: 'af5c3670-9b0f-4d86-b3b9-19fe62006c39'4 *5 * Sample itemId value: '813def66-0f0b-40b7-a9df-c731345a926f'6 */78export async function myGetGalleryItemFunction(galleryId, itemId) {9 try {10 const galleryItem = await proGallery.getGalleryItem({galleryId, itemId});1112 const galleryItemId = galleryItem._id;13 const galleryItemTitle = galleryItem.title;1415 console.log('Success! Got the gallery item:', galleryItem);16 return galleryItem;17 } catch (error) {18 console.error(error);19 // Handle the error20 }21}2223/* Promise resolves to:24 * {25 * "_createdDate": "Mon Feb 20 2021 15:22:15",26 * "_id": "813def66-0f0b-40b7-a9df-c731345a926f",27 * "_updatedDate": Tue Mar 30 2021 15:23:22,28 * "description": "This is the first item in my gallery.",29 * "image": {30 * "imageInfo": "wix:image://v1/38939f9568z222d6avc6285c9ac1e9129.jpg/38939f9568z222d6avc6285c9ac1e9129.jpg#originWidth=200&originHeight=199"31 * }32 * "sortOrder": 165743907518833 * "title": "My Gallery Item"34 * "type": "IMAGE"35 * }36 */