Firefox中的JCrop附加原始图像高度/宽度

Ans*_*was 5 css jquery jcrop

我们正在使用JCrop库来裁剪个人资料图片.当用户更改其个人资料照片时,新照片仍然使用旧图像尺寸.这适用于Chrome,但在Firefox中不起作用.我使用destroy删除了上一个图像和JCrop:

jcrop_api.destroy();
Run Code Online (Sandbox Code Playgroud)

我还添加了这行代码,试图清除包含宽度和高度的样式.

$('#target').removeAttr('style');
Run Code Online (Sandbox Code Playgroud)

小智 1

我也遇到了这个问题,我尝试了一切,终于发现了一个适合我的解决方法:

如果使用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();
}
Run Code Online (Sandbox Code Playgroud)