ability to restore original image

This commit is contained in:
Jakob Ketterl
2021-02-10 21:29:46 +01:00
parent 8cf9b509c1
commit 7097dc1cd8
4 changed files with 25 additions and 12 deletions

View File

@ -1,11 +1,13 @@
$.fn.imageUpload = function() {
$.each(this, function(){
var $button = $(this).find('button');
var $uploadButton = $(this).find('button.upload');
var $restoreButton = $(this).find('button.restore');
var $img = $(this).find('img');
var originalUrl = $img.prop('src');
var $input = $(this).find('input');
var id = $input.prop('id');
$button.click(function(){
$button.prop('disabled', true);
$uploadButton.click(function(){
$uploadButton.prop('disabled', true);
var input = document.createElement('input');
input.type = 'file';
input.accept = 'image/jpeg, image/png';
@ -25,7 +27,7 @@ $.fn.imageUpload = function() {
$input.val(data.uuid);
$img.prop('src', "/imageupload?id=" + id + "&uuid=" + data.uuid);
}).always(function(){
$button.prop('disabled', false);
$uploadButton.prop('disabled', false);
});
}
};
@ -33,5 +35,11 @@ $.fn.imageUpload = function() {
input.click();
return false;
});
$restoreButton.click(function(){
$input.val('restore');
$img.prop('src', originalUrl + "&mapped=false");
return false;
});
});
}