admin 发表于 2018-3-22 13:57:55

Discuz! x3.2 自定义网站附件图标解决的方案之一

修改方法:
找到文件:./source/function/function_attachment.php

如果需要的图标有,就修改红色部分就是的代码, } elseif(preg_match("/word|powerpoint|^(doc|docx|ppt|xls|xlsx)\t/", $type)) {
   $typeid = 5;就可以显示附件图标:

相关代码是:static $attachicons = array(
   1 => 'unknown.gif',
   2 => 'binary.gif',
   3 => 'zip.gif',
   4 => 'rar.gif',
   5 => 'msoffice.gif',
   6 => 'text.gif',
   7 => 'html.gif',
   8 => 'real.gif',
   9 => 'av.gif',
   10 => 'flash.gif',
   11 => 'image.gif',
   12 => 'pdf.gif',
   13 => 'torrent.gif'
);如果需要加入新图标,则需要上传图标文件到响应的文件夹:


上传图标至响应目录文件根目录/static/image/filetype/dwg.gif

完了修改相应增加的文件代码,红色部分
static $attachicons = array(
   1 => 'unknown.gif',
   2 => 'binary.gif',
   3 => 'zip.gif',
   4 => 'rar.gif',
   5 => 'msoffice.gif',
   6 => 'text.gif',
   7 => 'html.gif',
   8 => 'real.gif',
   9 => 'av.gif',
   10 => 'flash.gif',
   11 => 'image.gif',
   12 => 'pdf.gif',
   13 => 'dwg.gif',
   14 => 'torrent.gif'


} else {
if(preg_match("/bittorrent|^torrent\t/", $type)) {
   $typeid = 14;
} elseif(preg_match("/dwg|^dwg\t/", $type)) {
   $typeid = 13;
} elseif(preg_match("/pdf|^pdf\t/", $type)) {
   $typeid = 12;
} elseif(preg_match("/image|^(jpg|gif|png|bmp)\t/", $type)) {
   $typeid = 11;
完成后就会出现添加的图标,如图效果
页: [1]
查看完整版本: Discuz! x3.2 自定义网站附件图标解决的方案之一