Search...
onGalleryItemCreated( )
An event that triggers when a media item in a specified gallery is created.
Description
The onGalleryItemCreated()
event handler runs when a gallery item has been created. The received GalleryItemCreatedEvent
object contains information about the gallery item that was created.
Note: Backend events don't work when previewing your site.
Syntax
function onGalleryItemCreated(event: GalleryItemCreatedEvent): void
onGalleryItemCreated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
GalleryItemCreatedEvent
Information about a newly created gallery item.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event triggered when a gallery item is created
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixProGallery_onGalleryItemCreated(event) {6 const galleryItemId = event.data.item._id;7 const galleryItemDescription = event.data.item.description;8 const eventId = event.metadata.id;9 const eventTime = event.metadata.eventTime;10}1112/* Full event object:13 * {14 * "data": {15 * "item": {16 * "_createdDate": "2022-08-04T10:00:09.000Z",17 * "_id": "b082d5aa-1e7b-44d9-91f3-ab0387825de5",18 * "description": "The best addition to my gallery",19 * "sortOrder": 1,20 * "tags": {21 * "values": ["voice","bees","wind"]22 * },23 *. "title": "My New Item"24 * "type":"IMAGE",25 * "image": {26 * "type":"WIX_MEDIA",27 * "imageInfo": "wix:image://v1/9e6ea4_650d8cd45f7545c4b39178feb0ee8c70~mv2.jpg/300.jpg#originWidth=200&originHeight=300"28 * },29 * },30 * "metadata": {31 * "entityId": "b082d5aa-1e7b-44d9-91f3-ab0387825de5",32 * "eventTime": "2022-08-04T10:00:09.559484Z",33 * "id": "1586937f-a154-4ad1-8ccf-488a63852e63",34 * "triggeredByAnonymizeRequest": false35 * }36 * }37 */