Merge pull request #1620 from lostdalek/hotfix/PHRAS-899

PHRAS-899
This commit is contained in:
Benoît Burnichon
2016-01-11 09:52:45 +01:00
2 changed files with 41 additions and 30 deletions

View File

@@ -33,31 +33,36 @@
sequentialUploads: true,
add: function (e, data) {
$('#upload-error').empty();
$.each(data.files, function (index, file) {
var fileType = /^image\/(gif|jpeg|png)$/;
if(typeof loadImage == 'function' && fileType.test(file.type)){
if(file.size < 204800){ //200 ko
var options = {
maxWidth: 32,
maxHeight: 32,
minWidth: 32,
minHeight: 32
};
require([
"blueimp.loadimage"
], function (loadImage) {
data.oldImage = $("#img_before").get(0);
$.each(data.files, function (index, file) {
var fileType = /^image\/(gif|jpeg|png)$/;
if(typeof loadImage == 'function' && fileType.test(file.type)){
if(file.size < 204800){ //200 ko
var options = {
maxWidth: 32,
maxHeight: 32,
minWidth: 32,
minHeight: 32
};
loadImage(file, function(img){
$("#img_before").remove();
$("#pub_icon .thumb_wrapper").append(img);
$("#pub_icon .thumb_wrapper img").attr("img_before");
return false;
}, options);
data.oldImage = $("#img_before").get(0);
data.submit();
} else {
$('#upload-error').empty().append(language.errorFileApiTooBig);
loadImage(file, function(img){
$("#img_before").remove();
$("#pub_icon .thumb_wrapper").append(img);
$("#pub_icon .thumb_wrapper img").attr("img_before");
return false;
}, options);
data.submit();
} else {
$('#upload-error').empty().append(language.errorFileApiTooBig);
}
}
}
});
});
},
done: function (e, data) {

View File

@@ -166,6 +166,7 @@
<script type="text/javascript">
$(document).ready(function(){
var selected_files = [];
@@ -182,15 +183,20 @@ $(document).ready(function(){
return false;
}
loadImage(file,function(img){
$('input[name='+data.paramName[0]+']').closest('.controls').find('.thumbnail').empty().append(img);
}, {
fileType: /^image\/(gif|jpeg|png|jpg)$/,
maxSize : 5242880, // 5MB
maxWidth: 16,
maxHeight: 16,
minWidth: 16,
minHeight: 16
require([
"blueimp.loadimage"
], function (loadImage) {
loadImage(file,function(img){
$('input[name='+data.paramName[0]+']').closest('.controls').find('.thumbnail').empty().append(img);
}, {
fileType: /^image\/(gif|jpeg|png|jpg)$/,
maxSize : 5242880, // 5MB
maxWidth: 16,
maxHeight: 16,
minWidth: 16,
minHeight: 16
});
});
});