How can I remove one image from field type MediaGallery?

I connected a gallery to a dataset and the new field type MediaGallery. I have no problem of adding images to that record in the dataset.

But, now I want a DELETE IMAGE so that a user can delete the selected image. The problem that occurs now is the following.

When I get the currentItem from the dataset and console.log the field “images” which is the MediaGallery field I get this.


So for some reason one image is added to the gallery as an image:// and the other as a wix:image. Then I use the below when DELETE BUTTON is clicked:

let currentItem = $w("#gallery").currentItem;

And I get the current selected image and console.log that and gets the below:

type: "Image" description: "" title: "" height: 2374 width: 2760 src: 

And now when it is added to the gallery it transforms to a wix:image so I can’t compare the src property of the image to know which one in the array I am supposed to delete.

Is this some bug or intentional? I guess I can add some key to the title and use that but it would make more sense to compare the src values of the images.

1 Like

Call the function before changing the type, when you call the src for the image to delete you run the function right after change if the ttype otherwise it won’t let you delete it be cause your file type still IMG

Please share your editor’s URL so we can inspect, on what page can we view the issue?