我正在使用 Dropzone 上传图片并注意到两个问题:
- 同一图像的缩略图生成在某些浏览器中失败,例如对于附加的图像,缩略图在 chrome 中正确生成,在 safari 中为空白,在 firefox 中仅为灰色背景。
- 在 Safari 浏览器中,大多数缩略图都能正确生成,但对于某些尺寸/宽高比则不然。例如再次附加图像,如果水平拉伸(stretch),safari 将生成缩略图,否则不会。
更新
我现在已经确定这是由缩略图宽度的“空”参数引起的。将其设置为一个值可修复所有浏览器中的问题。理想情况下,我想以其原始宽高比显示缩略图,但对于如上所述的某些尺寸/浏览器,这似乎是失败的。
是否有针对此问题的修复或解决方法,以便我可以以原始宽高比显示缩略图?
Dropzone 初始化代码:
var photosDropzone = new Dropzone("#photosContainer", { url: "{% url 'ajax_photo_upload_view' %}", maxFilesize: 4,
acceptedFiles: 'image/*', addRemoveLinks: true,
dictRemoveFile:'Delete', thumbnailHeight:160, thumbnailWidth:null, });
最佳答案
尝试使用以下 CSS
.dropzone .dz-default.dz-message {
opacity: 1;
-ms-filter: none;
-webkit-filter: none;
filter: none;
-webkit-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
background: #fff;
background-repeat: no-repeat;
background-position: 0 0;
position: absolute;
width: 428px;
height: 123px;
margin-left: -214px;
margin-top: -61.5px;
top: 50%;
left: 50%;
font-size: 20px;
}
.dropzone .dz-preview{
margin: 0 10px !important;
}
.thumbnail {
height: 150px;
width: 150px;
margin: 10px;
}
.thumbnail img{
min-height: 100px;
min-width: 100px;
height: 100px;
width: 100px;
}
.dropzone img {
border-radius: 10px;
vertical-align: middle;
min-width: 100px;
min-height: 100px;
}
关于javascript - Dropzone 跨平台缩略图生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31488878/