我们正在使用 JCrop用于裁剪个人资料图片的库。当用户更改他的个人资料图片时,新图片仍然使用旧图片尺寸。这适用于 Chrome,但不适用于 Firefox。我使用 destroy 删除了之前的图像和 JCrop:
jcrop_api.destroy();
我还添加了这行代码,试图清除包含宽度和高度的样式。
$('#target').removeAttr('style');
最佳答案
我也遇到过这个问题,我尝试了所有方法并最终找到了适合我的解决方法:
如果再次使用Firefox和jcrop销毁和初始化,必须有一个alert()函数。
// Clear selector
if (jcropAPI) {
jcropAPI.destroy();
}
initCropper();
// If browser is Firefox, fix bug with stretching
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
// Do Firefox-related activities
alert('File successfully loaded'); // this alert is necessary
if (jcropAPI) {
jcropAPI.destroy();
}
initCropper();
}
关于jquery - Firefox 中的 JCrop 附加原始图像高度/宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18500960/