Discuz x3.4 附件图标问号及添加自定义附件图标方案

[复制链接] [添加相关主题]
godkings 发表于 2019-9-22 10:24:55
今天在论坛发布了一个excel文档,发现有一个大问号,搜索了一下遇见这个问题的还挺多,不过还好有大神,所以我的问题也解决了,特此记录一下。

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

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

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

其实打开就能看到下面这些内容,:
  1. function attachtype($type, $returnval = ‘html’) {
  2. static $attachicons = array(
  3. 1 => ‘unknown.gif’,
  4. 2 => ‘binary.gif’,
  5. 3 => ‘zip.gif’,
  6. 4 => ‘rar.gif’,
  7. 5 => ‘msoffice.gif’,
  8. 6 => ‘text.gif’,
  9. 7 => ‘html.gif’,
  10. 8 => ‘real.gif’,
  11. 9 => ‘av.gif’,
  12. 10 => ‘flash.gif’,
  13. 11 => ‘image.gif’,
  14. 12 => ‘pdf.gif’,
  15. 13=> ‘torrent.gif’
  16. );
复制代码


修改为你要添加的图标名称,例如我的,在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’
);

上面添加图标的修改完了,下面的也需要修改,搜索:
  1. if(is_numeric($type)) {
  2. $typeid = $type;
  3. } else {
  4. if(preg_match(“/bittorrent|^torrent\t/”, $type)) {
  5. $typeid = 13;
  6. } elseif(preg_match(“/pdf|^pdf\t/”, $type)) {
  7. $typeid = 12;
  8. } elseif(preg_match(“/image|^(jpg|gif|png|bmp)\t/”, $type)) {
  9. $typeid = 11;
  10. } elseif(preg_match(“/flash|^(swf|fla|flv|swi)\t/”, $type)) {
  11. $typeid = 10;
  12. } elseif(preg_match(“/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/”, $type)) {
  13. $typeid = 9;
  14. } elseif(preg_match(“/real|^(ra|rm|rv)\t/”, $type)) {
  15. $typeid = 8;
  16. } elseif(preg_match(“/htm|^(php|js|pl|cgi|asp)\t/”, $type)) {
  17. $typeid = 7;
  18. } elseif(preg_match(“/text|^(txt|rtf|wri|chm)\t/”, $type)) {
  19. $typeid = 6;
  20. } elseif(preg_match(“/word|powerpoint|^(doc|ppt)\t/”, $type)) {
  21. $typeid = 5;
  22. } elseif(preg_match(“/^rar\t/”, $type)) {
  23. $typeid = 4;
  24. } elseif(preg_match(“/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/”, $type)) {
  25. $typeid = 3;
  26. } elseif(preg_match(“/octet-stream|^(exe|com|bat|dll)\t/”, $type)) {
  27. $typeid = 2;
  28. } elseif($type) {
  29. $typeid = 1;
  30. } else {
  31. $typeid = 0;
  32. }
  33. }
复制代码


修改为:
  1. if(is_numeric($type)) {
  2. $typeid = $type;
  3. } else {
  4. if(preg_match(“/bittorrent|^torrent\t/”, $type)) {
  5. $typeid = 16;
  6. } elseif(preg_match(“/office|^(ppt)\t/”, $type)) {
  7. $typeid = 15;
  8. } elseif(preg_match(“/office|^(doc|docx)\t/”, $type)) {
  9. $typeid = 14;
  10. } elseif(preg_match(“/office|^(xls|xlsx)\t/”, $type)) {
  11. $typeid = 13;
  12. } elseif(preg_match(“/pdf|^pdf\t/”, $type)) {
  13. $typeid = 12;
  14. } elseif(preg_match(“/image|^(jpg|gif|png|bmp)\t/”, $type)) {
  15. $typeid = 11;
  16. } elseif(preg_match(“/flash|^(swf|fla|flv|swi)\t/”, $type)) {
  17. $typeid = 10;
  18. } elseif(preg_match(“/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/”, $type)) {
  19. $typeid = 9;
  20. } elseif(preg_match(“/real|^(ra|rm|rv)\t/”, $type)) {
  21. $typeid = 8;
  22. } elseif(preg_match(“/htm|^(php|js|pl|cgi|asp)\t/”, $type)) {
  23. $typeid = 7;
  24. } elseif(preg_match(“/text|^(txt|rtf|wri|chm)\t/”, $type)) {
  25. $typeid = 6;
  26. } elseif(preg_match(“/word|powerpoint|^(doc|ppt)\t/”, $type)) {
  27. $typeid = 5;
  28. } elseif(preg_match(“/^rar\t/”, $type)) {
  29. $typeid = 4;
  30. } elseif(preg_match(“/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/”, $type)) {
  31. $typeid = 3;
  32. } elseif(preg_match(“/octet-stream|^(exe|com|bat|dll)\t/”, $type)) {
  33. $typeid = 2;
  34. } elseif($type) {
  35. $typeid = 1;
  36. } else {
  37. $typeid = 0;
  38. }
  39. }
复制代码


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


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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x


上一篇:discuz修改帖子虚拟浏览量初始数量的方法
下一篇:Discuz! X3.4主题分类和分类信息伪静态设置方法

相关帖子

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ| Archiver|小黑屋| 颠覆霸主 ( 京ICP备12023415号-2 )

声明:本站的任何信息和内容仅代表作者的立场和观点,与颠覆霸主网无关。

禁止在颠覆霸主网发布任何与《中华人民共和国法律》相抵触的言论!

GMT+8, 2023-3-21 10:27 , Processed in 0.111385 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.