Discuz论坛中新增文件类型图标的方法
来源:互联网 发布:电脑隐藏软件 编辑:程序博客网 时间:2024/05/21 08:57
# 新增文件类型图标的方法
pptx文件不在论坛默认的文件类型范围之内,因此上传的pptx文件图标显示为未知,这对于我这种强迫症患者怎么可以忍受,解决方案如下
## 图片文件的下载
网上十分容易下载,修改成32x32大小,并且命名为“pptx.jpg”,存放在static/image/filetype目录下即可,接下来需要在源代码中做些许修改
## 增添新的文件类型
相关代码文件是source/function/function_attachment.php
```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'
);
```
我们需要在末尾增加一个新的图片文件,注意逗号!
```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',
14 => 'pptx.jpg'
);
```
此外,需要在接下来的代码上设置文件类型关联,修改前的代码如下
```php
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;
```
修改之后则变成
```php
if(is_numeric($type)) {
$typeid = $type;
} else {
if(preg_match("/ppt|^(pptx|ppt)\t/", $type)) {
$typeid = 14;
} elseif(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;
```
如此以来,我们就完成了新的文件类型图片的添加,在论坛上可以做尝试了,前后对比结果如下
修改前:
修改后:
显然,问题得到成功解决!
pptx文件不在论坛默认的文件类型范围之内,因此上传的pptx文件图标显示为未知,这对于我这种强迫症患者怎么可以忍受,解决方案如下
## 图片文件的下载
网上十分容易下载,修改成32x32大小,并且命名为“pptx.jpg”,存放在static/image/filetype目录下即可,接下来需要在源代码中做些许修改
## 增添新的文件类型
相关代码文件是source/function/function_attachment.php
```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'
);
```
我们需要在末尾增加一个新的图片文件,注意逗号!
```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',
14 => 'pptx.jpg'
);
```
此外,需要在接下来的代码上设置文件类型关联,修改前的代码如下
```php
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;
```
修改之后则变成
```php
if(is_numeric($type)) {
$typeid = $type;
} else {
if(preg_match("/ppt|^(pptx|ppt)\t/", $type)) {
$typeid = 14;
} elseif(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;
```
如此以来,我们就完成了新的文件类型图片的添加,在论坛上可以做尝试了,前后对比结果如下
修改前:
修改后:
显然,问题得到成功解决!
阅读全文
0 0
- Discuz论坛中新增文件类型图标的方法
- 在Win2003中架设Discuz!论坛的方法
- destoon调用discuz论坛中带图片帖子的方法
- Discuz!论坛教程之去掉帖子列表页的附件图标的方法
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- Discuz论坛防止广告机的方法
- 有关文件类型的图标更改方法
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法 (转)
- discuz论坛添加、更换返回顶部图标
- discuz论坛的安装
- discuz论坛的抓取
- Discuz! BBS(论坛)迁移方法
- Discuz! BBS(论坛)迁移方法
- 【discuz】discuz论坛系统中自定义广告位
- SQL Date 函数
- 修改Pip 管理工具默认下载源
- 2017-09-12 LeetCode_215 Kth Largest Element in an Array
- android studio开发整合资源简单实现android扫一扫功能
- PHP,jQuery插件,生成二维码
- Discuz论坛中新增文件类型图标的方法
- 【20170912】校招走到一半,屡败屡战!
- can总线基础(一)
- java socket报文通信(二)报文的封装
- 生成对抗网络
- yuyv转rgb,rgb转bmp,已验证
- Lombok 安装、入门
- Elasticsearch_初始化配置
- IntelliJ IDEA设置JDK