I'm using wordpress. I want to make a script that will delete images from gallery. I have a script that deletes images when I click on button. Although it deletes them just from page, not server so if I save changes and reload page, images will not be deleted. I have a script that deletes all photos and this one should work likewise.
Script that removes all photos:
'click .butterbean-remove-media' : 'removemedia'
this.model.set( {
src : media.filename,
value : media.id
} );
removemedia : function() {
// Updates the model for the view.
this.model.set( { src : '', value : '' } );
}
I think that ajax script should look like this:
jQuery( function( $ ){
$(document).on('click', '.image-remove-btn', function (e){
$.ajax({
url: ajaxurl,
type: 'POST',
data: 'param1=2¶m2=3',
success: function( data ) {
$(this).closest('.thumbs').remove();
}
});
});
});
But I don't know what should be placed in data
. I suppose that data-id
that have every img
.
You must first get the special id of the image you want to delete (clicked).
To get this; The element of the clicked image must have a special id of the clicked image anywhere. Server with ajax by taking this ID of yours
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.