This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
An event that triggers when a media item in a specified gallery is created.
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.
function wixProGallery_onGalleryItemCreated(
event: GalleryItemCreatedEvent,
): void;
Information about a newly created gallery item.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixProGallery_onGalleryItemCreated(event) {
const galleryItemId = event.data.item._id;
const galleryItemDescription = event.data.item.description;
const eventId = event.metadata.id;
const eventTime = event.metadata.eventTime;
}
/* Full event object:
* {
* "data": {
* "item": {
* "_createdDate": "2022-08-04T10:00:09.000Z",
* "_id": "b082d5aa-1e7b-44d9-91f3-ab0387825de5",
* "description": "The best addition to my gallery",
* "sortOrder": 1,
* "tags": {
* "values": ["voice","bees","wind"]
* },
*. "title": "My New Item"
* "type":"IMAGE",
* "image": {
* "type":"WIX_MEDIA",
* "imageInfo": "wix:image://v1/9e6ea4_650d8cd45f7545c4b39178feb0ee8c70~mv2.jpg/300.jpg#originWidth=200&originHeight=300"
* },
* },
* "metadata": {
* "entityId": "b082d5aa-1e7b-44d9-91f3-ab0387825de5",
* "eventTime": "2022-08-04T10:00:09.559484Z",
* "id": "1586937f-a154-4ad1-8ccf-488a63852e63",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.