-
设置缩略图大小
- 系统 -> 附件设置,将缩略图默认宽度、高度设为大于等于全站所有调用缩略图的最大尺寸。
-
修改
include/extend.func.php
文件- 在文件末尾添加以下代码:
function thumb($imgurl, $width, $height, $bg = true) { global $cfg_mainsite, $cfg_multi_site; $thumb = eregi("", $imgurl) ? str_replace($cfg_mainsite, "", $imgurl) : $imgurl; list($thumbname, $extname) = explode('.', $thumb); $newthumb = $thumbname . '_' . $width . '_' . $height . '.' . $extname; if (!$thumbname || !$extname || !file_exists(DEDEROOT . $thumb)) return $imgurl; if (!file_exists(DEDEROOT . $newthumb)) { include_once DEDEINC . '/image.func.php'; if ($bg == true) { ImageResizeNew(DEDEROOT . $thumb, $width, $height, DEDEROOT . $newthumb); } else { ImageResize(DEDEROOT . $thumb, $width, $height, DEDEROOT . $newthumb); } } return $cfg_multi_site == 'Y' ? $cfg_mainsite . $newthumb : $newthumb; }
- 在文件末尾添加以下代码:
-
调用方法
[field:picname function='thumb(@me, 100, 100)' /]
参数说明:
$width
: 缩略图宽度(整数)$height
: 缩略图高度(整数)$bg
: 是否用空白填补,默认自动填补,背景填充颜色在系统 -> 附件设置里(true/false)

