Media Gallery Database Images Missing

I set up a gallery connected to a database media gallery. Coded an upload button to push images to the gallery and then save to the database. It works, but when I open the images as the site ADMIN and close the galley window the images disappear leaving only a remnant of an image that used to be there. Here is my code-

export function uploadButton4_change(event) {
$w(“#uploadButton4”).startUpload()
.then((uploadedFile) => {
let url = uploadedFile.url;
let items = $w(“#gallery1”).items;
items.push({
“src”: uploadedFile.url,
“description”: “”,
“title”: “”
});
$w(“#gallery1”).items = items;
$w(“#uploadButton4”).reset();
})
.then(() => {
let items = $w(‘#gallery1’).items;
$w(‘#dataset1’).setFieldValue(“image2”, items);
$w(“#dataset1”).save();
$w(‘#dataset1’).refresh();
})
. catch ((uploadError) => {
let errCode = uploadError.errorCode;
let errDesc = uploadError.errorDescription;
});
}

Initial View

When I open the gallery


After I click done when viewing


Then when I open it again


What the heck is happening to the images?

1 Like

website link if it helps
lvlsocial.com

The only thing that I see is odd is that every time an image is uploaded a new entry is put in the database. This may cause odd behavior but i’m not sure if that’s your problem.

Thank you for the insight! I’ll be tinkering with it to see if I can find a solution.

@ycazes I’m not sure of your actual setup but mine is done with a submit button. Once all the required pictures are loaded into the gallery, submit pushes them into the database and then clears the form. This happens with a write only data base.

If you want to use just an upload button you may be able to hold a variable in wix data session. Have a read/write data base. When the first image is loaded set a flag to true. Then while the flag is true every subsequent image is added. When the page is reloaded reset the flag back to false. If the flag is false start a new entry.

Any luck? Having the exact same problem now with all Media Galleries, (The ones I build in the database and the ones I code together.)