WenRou's Blog
Discuz! x3.2 附件图标问号及添加自定义附件图标方案
2015-3-13 温柔哥


今天在论坛发布了一个excel文档,发现有一个大问号,搜索了一下遇见这个问题的还挺多,不过还好有大神,所以我的问题也解决了,特此记录一下。



Discuz! x3.2 附件图标问号的解决方法



1、将图标上传到目录:static\image\filetype 保存为你需要的名字,比如我的,xls.gif



2、打开文件,路径为:\source\function\function_attachment.php



其实打开就能看到下面这些内容,:




function attachtype($type, $returnval = ‘html’) {



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’

);




修改为你要添加的图标名称,例如我的,在12和13中间加上这些:




function attachtype($type, $returnval = ‘html’) {



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 => ‘xls.gif’,

14 => ‘doc.gif’,

15 => ‘ppt.gif’,

16 => ‘torrent.gif’

);




上面添加图标的修改完了,下面的也需要修改,搜索:




if(is_numeric($type)) {

$typeid = $type;

} else {

if(preg_match(“/bittorrent|^torrent\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;

} elseif(preg_match(“/flash|^(swf|fla|flv|swi)\t/”, $type)) {

$typeid = 10;

} elseif(preg_match(“/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/”, $type)) {

$typeid = 9;

} elseif(preg_match(“/real|^(ra|rm|rv)\t/”, $type)) {

$typeid = 8;

} elseif(preg_match(“/htm|^(php|js|pl|cgi|asp)\t/”, $type)) {

$typeid = 7;

} elseif(preg_match(“/text|^(txt|rtf|wri|chm)\t/”, $type)) {

$typeid = 6;

} elseif(preg_match(“/word|powerpoint|^(doc|ppt)\t/”, $type)) {

$typeid = 5;

} elseif(preg_match(“/^rar\t/”, $type)) {

$typeid = 4;

} elseif(preg_match(“/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/”, $type)) {

$typeid = 3;

} elseif(preg_match(“/octet-stream|^(exe|com|bat|dll)\t/”, $type)) {

$typeid = 2;

} elseif($type) {

$typeid = 1;

} else {

$typeid = 0;

}

}




修改为:




if(is_numeric($type)) {

$typeid = $type;

} else {

if(preg_match(“/bittorrent|^torrent\t/”, $type)) {

$typeid = 16;

} elseif(preg_match(“/office|^(ppt)\t/”, $type)) {

$typeid = 15;

} elseif(preg_match(“/office|^(doc|docx)\t/”, $type)) {

$typeid = 14;

} elseif(preg_match(“/office|^(xls|xlsx)\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;

} elseif(preg_match(“/flash|^(swf|fla|flv|swi)\t/”, $type)) {

$typeid = 10;

} elseif(preg_match(“/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/”, $type)) {

$typeid = 9;

} elseif(preg_match(“/real|^(ra|rm|rv)\t/”, $type)) {

$typeid = 8;

} elseif(preg_match(“/htm|^(php|js|pl|cgi|asp)\t/”, $type)) {

$typeid = 7;

} elseif(preg_match(“/text|^(txt|rtf|wri|chm)\t/”, $type)) {

$typeid = 6;

} elseif(preg_match(“/word|powerpoint|^(doc|ppt)\t/”, $type)) {

$typeid = 5;

} elseif(preg_match(“/^rar\t/”, $type)) {

$typeid = 4;

} elseif(preg_match(“/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/”, $type)) {

$typeid = 3;

} elseif(preg_match(“/octet-stream|^(exe|com|bat|dll)\t/”, $type)) {

$typeid = 2;

} elseif($type) {

$typeid = 1;

} else {

$typeid = 0;

}

}




修改完成,登陆后台,更新缓存,上传文件测试一下就可以了。



修改前:



Discuz! x3.2 附件图标问号及添加自定义附件图标方案 - 冰糖葫芦 - 1



修改后:



Discuz! x3.2 附件图标问号及添加自定义附件图标方案 - 冰糖葫芦 - 2



到这里大家应该能看明白了,需要哪些图标就自己添加就可以了,这个还是比较简单的哈。



附上我的图标,有需要的小伙伴可以一并带走哈



Discuz! x3.2 附件图标问号及添加自定义附件图标方案 - 冰糖葫芦 - 3 Discuz! x3.2 附件图标问号及添加自定义附件图标方案 - 冰糖葫芦 - 4 Discuz! x3.2 附件图标问号及添加自定义附件图标方案 - 冰糖葫芦 - 5 Discuz! x3.2 附件图标问号及添加自定义附件图标方案 - 冰糖葫芦 - 6(右键另存为就可以了)

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容