# How can I remove one image from field type MediaGallery?

**URL:** <https://forum.wixstudio.com/t/how-can-i-remove-one-image-from-field-type-mediagallery/13971>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [November 20, 2018, 3:02pm UTC](https://forum.wixstudio.com/t/how-can-i-remove-one-image-from-field-type-mediagallery/13971 "2018-11-20T15:02:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas-kviby](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andreas-kviby/32/790_2.png) [@andreas-kviby](https://forum.wixstudio.com/u/andreas-kviby)\
**Post date:** [November 20, 2018, 3:02pm UTC](https://forum.wixstudio.com/t/how-can-i-remove-one-image-from-field-type-mediagallery/13971/1 "2018-11-20T15:02:18Z")

</div>

Hey  
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.

```javascript
0: 
"{\"type\":\"Image\",\"description\":\"\",\"title\":\"\",\"height\":2558,\"width\":2052,\"src\":\"wix:image://v1/19819c_5f4c5a616915446494cedc0084c17872~mv2_d_2052_2558_s_2.png/_.png#originWidth=2052&originHeight=2558\"}"
1: 
"{\"src\":\"image://v1/19819c_3d02076f2c034b3988449ee2a22d08a4~mv2_d_2760_2374_s_2.png/2760_2374/19819c_3d02076f2c034b3988449ee2a22d08a4~mv2_d_2760_2374_s_2.png\",\"description\":\"\",\"title\":\"\"}"

```

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:

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

```

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

```javascript
type: "Image" description: "" title: "" height: 2374 width: 2760 src: 
"wix:image://v1/19819c_3d02076f2c034b3988449ee2a22d08a4~mv2_d_2760_2374_s_2.png/_.png#originWidth=2760&originHeight=2374"

```

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.

---

<div class="post-metadata">

**Author:** ![carlosgalvarez](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/carlosgalvarez/32/2194_2.png) [@carlosgalvarez](https://forum.wixstudio.com/u/carlosgalvarez)\
**Post date:** [November 20, 2018, 6:21pm UTC](https://forum.wixstudio.com/t/how-can-i-remove-one-image-from-field-type-mediagallery/13971/2 "2018-11-20T18:21:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![\_or](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_or/32/1004_2.png) [@\_or](https://forum.wixstudio.com/u/_or)\
**Post date:** [December 2, 2018, 1:24pm UTC](https://forum.wixstudio.com/t/how-can-i-remove-one-image-from-field-type-mediagallery/13971/3 "2018-12-02T13:24:51Z")

</div>

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