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

标签 jquery css jcrop

我们正在使用 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/

相关文章:

css - 如何修复模糊的图像

html - 底部页面上的孤儿 CSS : How avoid headers (h1, h2...)?

javascript - 在 JCrop 上设置最小高度和宽度

javascript - 在溢出 : auto 的 div 中仅滚动一次 'var distance'

javascript - 如何使用 Meteor 事件转动按钮并反转它们?

javascript - Socialfeed.js 没有显示任何内容,但也没有错误

javascript - 在 Select2 标签文本区域中创建新标签

css - 如何在 Xamarin 中使用 CSS 设置自定义字体系列

javascript - 使用 Jcrop 调整图像大小

jQuery 不更新元素的 CSS 高度和宽度