javascript - 有没有办法使用默认的 Word 或 PDF 图像/图标作为缩略图而不是通用的灰色背景?

标签 javascript css dropzone.js

我想在 dropzone 文件预览中更改 word/pdf 文件的通用灰色背景。这是默认 View :

enter image description here

哪种方法最好?

最佳答案

这是我最终做到的方式:

myAwesomeDropzone.on('addedfile', function(file) {

    var ext = file.name.split('.').pop();

    if (ext == "pdf") {
        $(file.previewElement).find(".dz-image img").attr("src", "/Content/Images/pdf.png");
    } else if (ext.indexOf("doc") != -1) {
        $(file.previewElement).find(".dz-image img").attr("src", "/Content/Images/word.png");
    } else if (ext.indexOf("xls") != -1) {
        $(file.previewElement).find(".dz-image img").attr("src", "/Content/Images/excel.png");
    }
});

图像必须为 120x120 像素才能适合默认预览模板。

这是结果:

enter image description here

关于javascript - 有没有办法使用默认的 Word 或 PDF 图像/图标作为缩略图而不是通用的灰色背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31840374/

相关文章:

php - 无法使用 dropzone 上传多个文件

javascript - vuejs - 当我保存文件时,npm run dev webserver 自动刷新有效,但刷新浏览器不起作用

html - 如何在单击时更改无序列表的宽度

iOS 设备的 HTML/CSS 悬停翻转可见性问题

asp.net-mvc - 允许 Dropzone js 仅上传 zip 文件

java - 在Java中上传Excel文件时如何修复错误415不支持的媒体类型错误?

javascript - jquery 中的 CSS 和 animate()

javascript - 如何最好地在 ASP.NET MVC 中将网格导出为 PDF

javascript - 在硬编码处理程序周围包装 jquery 事件处理程序

html - 当第一个里面有绝对定位时,如何让外部 div 正确堆叠?