找回密码
 立即注册

QQ登录

只需一步,快速开始

Discuz! x3.2 添加自定义附件图标方案之一(附件图标问号解决)-案例添加apk显示图标

方案说明:Discuz!x3.2在使用是,对于未知的文件类型,直接显示问号图标,为了让站长自己的文件类型能显示正确图标,特分享以下教材。
适用版本:Discuz!x2.5-x3.2
解决流程:案例 添加apk显示图标
1.将apk图 apk.png 上传到目录:static\image\filetype
保存为apk.png
2.打开文件,路径为:
\source\function\function_attachment.php
3.搜索:
  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.                 );
复制代码
改为:
  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 => 'apk.png',
  16.                         14 => 'torrent.gif'
  17.                 );
复制代码
搜索:
  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 = 14;
  6.                 } elseif(preg_match("/apk|^apk\t/", $type)) {
  7.                         $typeid = 13;
  8.                 } elseif(preg_match("/pdf|^pdf\t/", $type)) {
  9.                         $typeid = 12;
  10.                 } elseif(preg_match("/image|^(jpg|gif|png|bmp)\t/", $type)) {
  11.                         $typeid = 11;
  12.                 } elseif(preg_match("/flash|^(swf|fla|flv|swi)\t/", $type)) {
  13.                         $typeid = 10;
  14.                 } elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/", $type)) {
  15.                         $typeid = 9;
  16.                 } elseif(preg_match("/real|^(ra|rm|rv)\t/", $type)) {
  17.                         $typeid = 8;
  18.                 } elseif(preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type)) {
  19.                         $typeid = 7;
  20.                 } elseif(preg_match("/text|^(txt|rtf|wri|chm)\t/", $type)) {
  21.                         $typeid = 6;
  22.                 } elseif(preg_match("/word|powerpoint|^(doc|ppt)\t/", $type)) {
  23.                         $typeid = 5;
  24.                 } elseif(preg_match("/^rar\t/", $type)) {
  25.                         $typeid = 4;
  26.                 } elseif(preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/", $type)) {
  27.                         $typeid = 3;
  28.                 } elseif(preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type)) {
  29.                         $typeid = 2;
  30.                 } elseif($type) {
  31.                         $typeid = 1;
  32.                 } else {
  33.                         $typeid = 0;
  34.                 }
  35.         }
复制代码

4.修改完成,覆盖同门文件,登陆后台,更新缓存,上传文件测试哦。
效果如下
QQ截图20140729112911.png




本教程由无限星辰工作室CRX349独家整理和提供,转载请注明地址,谢谢。本文地址:https://www.xmspace.net/thread-211-1-1.html
无限星辰工作室  好集导航 Discuz全集下载  星辰站长网  集热爱361  一品文学  手机小游戏合集   海外空间网 星辰api  星辰支付二维码管理平台 阿里云服务器 腾讯云服务器
服务Discuz!建站|DiscuzQ配置|二开|小程序|APP|搬家|挂马清理|防护|Win/Linux环境搭建|优化|运维|
服务理念:专业 诚信 友好QQ842062626 服务项目 Q群315524225

发表于 2014-7-29 11:32:07 | 显示全部楼层 |阅读模式

回复 | 使用道具 举报

该帖共收到 0 条回复!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

美图秀

    • fastadmin 后台界面使用字段数组类型
    • Discuz!x3.5 修改标题高亮颜色
    • Discuz!x3.5 应用中心 下载应用一直下载中
    • 帖子定时显示
    • 论坛辅助审核
拖动客服框
Online Service
点击这里给我发消息
点击这里联系我们
微信扫一扫
在线客服
快速回复 返回顶部 返回列表