Javascript Dropzone.js正在获取用于预览的图像
我正在尝试获取在Dropzone中排队的真实图像并显示预览,但我唯一能获取的图像是缩略图,有没有方法获取真实图像 这是我的密码:Javascript Dropzone.js正在获取用于预览的图像,javascript,dropzone.js,Javascript,Dropzone.js,我正在尝试获取在Dropzone中排队的真实图像并显示预览,但我唯一能获取的图像是缩略图,有没有方法获取真实图像 这是我的密码: var uploadDrop = new Dropzone("#my-awesome-dropzone", { acceptedFiles: "image/png", url: "${g.createLink(controller:'perfil',action: 'saveFile')}", maxFiles: 1, /
var uploadDrop = new Dropzone("#my-awesome-dropzone", {
acceptedFiles: "image/png",
url: "${g.createLink(controller:'perfil',action: 'saveFile')}",
maxFiles: 1, // Number of files at a time
maxFilesize: 1, //in MB
autoProcessQueue: false,
maxfilesexceeded: function(file){
alert('You have uploaded more than 1 Image. Only the first file will be uploaded!');
},
init: function(){
this.on("addedfile", function() {
if (this.files[1]!=null){
this.removeFile(this.files[0]);
}
});
},
thumbnail: function(file, dataUrl) {
// Display the image in your file.previewElement
$(file.previewElement).removeClass("dz-file-preview").addClass("dz-image-preview");
$(file.previewElement).find(".dz-image img").attr("src",dataUrl);
$("#preview").attr("src",dataUrl);
},
success: function (response) {
var x = JSON.parse(response.xhr.responseText);
var message=x.data.message;
if (message.pass) {
originalLogoName=x.data.data.logoName
pasoPorSubida=true;
simpleMessage(message.title, message.body, "success");
this.removeAllFiles(); // This removes all files after upload to reset dropzone for next upload
} else {
simpleMessage(message.title, message.body, "error");
}
},
addRemoveLinks: true,
removedfile: function(file) {
var _ref; // Remove file on clicking the 'Remove file' button
if(!success){
$("#preview").attr("src",originalLogoUrl+"/"+originalLogoName);
}else{
success=false;
}
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
我不确定你想实现什么,但我认为最好的方法应该是上传图像,然后获取url并加载图像,如果你不想上传图像,可以查看dropzone选项
thumbnailWidth
和thumbnailHeight
。将它们设置为null将不会调整缩略图的大小,但这可能会造成较大的延迟images@wallek876谢谢你的回复,在对缩略图的大小进行一点调整后,我可以得到我想要的图像,谢谢你的建议!!。