discuz插件的事,我又跑到csdn来问,相信组织的力量!
这个插件呢,是仿贴吧的,在帖子列表显示缩略图,是我很喜欢的一种风格,适用于X3.0,但是为了客户端,我只能用X2.5版本,这个插件在X2.5不工作,无法生成缩略图我就是想改一改代码,让其在X2.5环境下工作,自用,不商用。
在X3.0下,是能生成一个存放缩略图的文件夹,里面存放有缩略图。但是在2.5下,没有发现这个文件夹,所以感觉在build这一步出了问题。
下面贴出thumbbuilder.class.php这个文件的代码,请高手分析一下,为什么没有在data/attachment/下生成tiebalist这个文件夹。
<?phpif(!defined('IN_DISCUZ')) { exit('Access Denied');}if (!class_exists('PhpThumbFactory',false)) require_once('source/plugin/chs_tiebalist/phpthumb/ThumbLib.inc.php');class ThumbBuilder { private $basedir; private $baseurl; public function __construct(){ global $_G; $this->basedir=!$_G['setting']['attachdir'] ? (DISCUZ_ROOT.'data/attachment/'):$_G['setting']['attachdir']; $this->baseurl=!$_G['setting']['attachurl'] ? ('data/attachment/'):$_G['setting']['attachurl']; } private function getCoverPath($tid){ return 'tiebalist/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/'; } public function GetThreadCovers($tid,$aids){ $coverpath=$this->getCoverPath($tid); $fullpath=$this->basedir.$coverpath; $fullurl=$this->baseurl.$coverpath; $images=array(); foreach($aids as $aid){ if (file_exists($fullpath.$aid.'.jpg')) $images[]=array('aid'=>$aid,'thumbfile'=>$fullurl.$aid.'.jpg'); } return $images; } public function CreateThreadCovers($tid,$images,$force=0){ $path=$this->basedir.$this->getCoverPath($tid); dmkdir($path); global $_G; $setting=&$_G['cache']['plugin']['chs_tiebalist']; $thumbheight=$setting['thumbheight']?$setting['thumbheight']:80; $thumbmaxwidth=$setting['thumbmaxwidth']?$setting['thumbmaxwidth']:300; foreach($images as $aid=>$image){ $target=$path.$aid.'.jpg'; if (file_exists($target)&&(!$force)) continue; try { $thumb = PhpThumbFactory::create($image,array('resizeUp'=>true)); $dimensions=$thumb->getCurrentDimensions(); $newwidth=$thumbheight*$dimensions['width']/$dimensions['height']; if ($newwidth>$thumbmaxwidth) { $thumb->adaptiveResize($thumbmaxwidth,$thumbheight); }else { $thumb->resize(0,$thumbheight);//封面不限定宽度 } $thumb->save($target); }catch(Exception $oEx){//捕获生成缩略图可能抛出的异常,防止中断 writelog('tiebalistlog',$oEx->getMessage()); continue; } } if ($force) { $thumbfiles=$this->getfiles($path,'jpg'); $aids=array_keys($images); foreach($thumbfiles as $filename){ $aid=intval(substr($filename,0,strpos($filename,'.'))); if (!in_array($aid,$aids)) unlink($path.$filename); } } } private function getfiles($dir,$mask=''){ $fileArray=array(); if (false != ($handle = opendir ($dir))) { while (false!==($file=readdir($handle))){ if ($file == '.' || $file == '..') continue; if (empty($mask)) $fileArray[]=$file; else if (substr(strrchr($file, '.'), 1)==$mask) $fileArray[]=$file; } } return $fileArray; }}?>
回复讨论(解决方案)
buildthumb.inc.php内的内容,好像也有用处呢
<?phpif(!defined('IN_DISCUZ')) { exit('Access Denied');}class plugin_chs_tiebalist { function common() {}}class plugin_chs_tiebalist_forum extends plugin_chs_tiebalist { function forumdisplay_thread_subject_output(){ global $_G; $setting=&$_G['cache']['plugin']['chs_tiebalist']; if (!$setting['enabled']) return; $fid = intval($_G['fid']); $forumselected=unserialize($setting['forumselected']); if(!in_array($fid,$forumselected)) return; if ($_G['forum']['picstyle'] == 0||$_G['cookie']['forumdefstyle']==1){ global $_G; $threadlist = array(); $threadlist = $_G['forum_threadlist']; $tiebalist = array(); $messagelength=$setting['messagelength']?$setting['messagelength']:100; $picturenum=$setting['$picturenum']?$setting['$picturenum']:3; include libfile('function/post'); require_once('thumbbuilder.class.php'); $oTB=new ThumbBuilder(); foreach($threadlist as $key => $value){ $position=($value['special']==2)?2:1;//商品主题的首帖在第二楼,回复从第3楼开始 $firstpost=C::t('forum_post')->fetch_all_by_tid_position('tid:'.$value['tid'],$value['tid'],$position); if (count($firstpost)>0&&$firstpost[0]['invisible']>=0){ $post=&$firstpost[0]; $message=messagecutstr($post['message'],$messagelength); $tiebalist[$key] = '<p>'.$message.'</p>'; $attachs=C::t('forum_attachment_n')->fetch_all_by_id('pid:'.$post['pid'],'pid',$post['pid'],false,true,false,false,$picturenum); $aids=array_keys($attachs); if ($aids){ $imagelist=$oTB->GetThreadCovers($value['tid'],$aids); if (count($imagelist)>0) { $tiebalist[$key].='<ul id="thumblist_'.$value['tid'].'" class="thumblist cl">'; foreach($imagelist as $ii=>$image){ $attach=$attachs[$image['aid']]; $forumimg=($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment']; $tiebalist[$key].='<li data="'.$forumimg.'" onclick="showpicture('.$value['tid'].','.$ii.');return false;"><img src="/static/imghw/default1.png" data-src="'.$image['thumbfile'].'" class="lazy" .$image['thumbfile'].'"/ alt="discuz插件的事,我又跑到csdn来问,相信组织的力量!" ></li>'; } $tiebalist[$key].='</ul>'; $tiebalist[$key].= '<div id="picturebox_'.$value['tid'].'" class="picturedisplay" style="max-width:90%"> <div class="picturecontrol"> <a class="icon_close" onclick="closepicture('.$value['tid'].');return false;">收起</a> <span>|</span> <a class="icon_viewpost" href="forum.php?mod=viewthread&tid='.$value['tid'].'&extra=page%3D1">查看帖子</a> <span>|</span> <a class="icon_turnleft" onclick="turnimg('.$value['tid'].',1);return false;">左转</a> <span>|</span> <a class="icon_turnright" onclick="turnimg('.$value['tid'].',0);return false;">右转</a> </div> <div class="picturewrap" > <a onclick="closepicture('.$value['tid'].');return false;"><img class="picture lazy" src="/static/imghw/default1.png" data-src="" / alt="discuz插件的事,我又跑到csdn来问,相信组织的力量!" ></a> <div class=" /></a> <div ></div> <div class="gonext"></div> </div> </div>'; } } } } return $tiebalist; } } function forumdisplay_threadlist_bottom() { global $_G; $setting=&$_G['cache']['plugin']['chs_tiebalist']; if (!$setting['enabled']) return; $fid = intval($_G['fid']); $forumselected=unserialize($setting['forumselected']); if(!in_array($fid,$forumselected)) return; $echo = '<link rel="stylesheet" type="text/css" href="source/plugin/chs_tiebalist/template/css/tiebalist.css" />'; $echo .= '<script src="source/plugin/chs_tiebalist/template/js/tiebalist.js" type="text/javascript"></script>'; $picturemaxwidth=$setting['picturemaxwidth']?$setting['picturemaxwidth']:600; $echo .='<script type="text/javascript">var picturemaxwidth='.$picturemaxwidth.';</script>'; return $echo; } function post_chs_tiebalist_message($params) { global $_G, $tid, $pid, $modthread, $isfirstpost; $setting=&$_G['cache']['plugin']['chs_tiebalist']; if (!$setting['enabled']) return; $fid = intval($_G['fid']); $forumselected=unserialize($setting['forumselected']); if(!in_array($fid,$forumselected)) return; list($msg, $url_forward, $values, $extraparam) = $params['param']; if (($msg == 'post_newthread_succeed')||($msg == 'post_newthread_mod_succeed')) { $pid = $modthread->pid; $this->create_covers($pid,$tid); dshowmessage($msg, $url_forward, $values, $extraparam); }else if (($msg == 'post_edit_succeed')&&$isfirstpost) { $tid=$_G['tid']; $this->create_covers($pid,$tid); dshowmessage($msg, $url_forward, $values, $extraparam); } } private function create_covers($pid,$tid){ global $_G; $setting=&$_G['cache']['plugin']['chs_tiebalist']; $picturenum=$setting['$picturenum']?$setting['$picturenum']:3; //获取帖子的图片 $attachs=C::t('forum_attachment_n')->fetch_all_by_id('pid:'.$pid,'pid',$pid,false,true,false,false,$picturenum); $images=array(); foreach($attachs as $attach){ $images[$attach['aid']]=($attach['remote'] ? $_G['setting']['ftp']['attachdir'] : $_G['setting']['attachdir']).'forum/'.$attach['attachment']; } if ($images){ require_once("thumbbuilder.class.php"); $oTB=new ThumbBuilder(); $oTB->CreateThreadCovers($tid,$images); } }}?>
这个你找原插件作者去瞅瞅吧!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PyCharm是一款功能强大且受欢迎的Python集成开发环境(IDE),提供了丰富的功能和工具,使得开发者们可以更加高效地编写代码。而PyCharm的插件机制更是其功能扩展的利器,通过安装不同的插件,可以为PyCharm增加各种功能和定制化的特性。因此,对于PyCharm新手来说,了解并熟练安装插件是至关重要的。本文将为你详细介绍PyCharm插件安装的全
![在Illustrator中加载插件时出错[修复]](https://img.php.cn/upload/article/000/465/014/170831522770626.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
启动AdobeIllustrator时是否会弹出加载插件时出错的消息?一些Illustrator用户在打开该应用程序时遇到了此错误。消息后面紧跟着一系列有问题的插件。该错误提示表明已安装的插件存在问题,但也可能是由于VisualC++DLL文件损坏或首选项文件受损等其他原因引起。如果遇到此错误,我们将在本文中指导您修复问题,请继续阅读以下内容。在Illustrator中加载插件时出错如果您在尝试启动AdobeIllustrator时收到“加载插件时出错”的错误消息,您可以使用以下用途:以管理员身

Chrome的插件扩展程序安装目录是什么?正常情况下,Chrome插件扩展程序的默认安装目录如下:1、windowsxp中chrome插件默认安装目录位置:C:\DocumentsandSettings\用户名\LocalSettings\ApplicationData\Google\Chrome\UserData\Default\Extensions2、windows7中chrome插件默认安装目录位置:C:\Users\用户名\AppData\Local\Google\Chrome\User

用户使用Edge浏览器的过程中可能会添加一些插件来满足自己更多的使用需求。但是在添加插件时显示不支持此插件,这该如何解决?今日小编就来给大家分享三种解决办法,快来试试吧。 方法一:尝试用其他的浏览器。 方法二:浏览器上的FlashPlayer可能过时或者丢失,导致此插件不受支持状态,可在官网下载最新版本。 方法三:同时按下“Ctrl+Shift+Delete”键。 点击“清除数据”,重新打开浏览器即可。

PyCharm社区版支持的插件足够吗?需要具体代码示例随着Python语言在软件开发领域的应用越来越广泛,PyCharm作为一款专业的Python集成开发环境(IDE),备受开发者青睐。PyCharm分为专业版和社区版两个版本,其中社区版是免费提供的,但其插件支持相对专业版有所限制。那么问题来了,PyCharm社区版支持的插件足够吗?本文将通过具体的代码示例

如何使用WordPress插件实现即时定位功能随着移动设备的普及,越来越多的网站开始提供基于地理位置的服务。在WordPress网站中,我们可以通过使用插件来实现即时定位功能,为访问者提供与地理位置相关的服务。一、选择适合的插件在WordPress插件库中有很多提供地理位置服务的插件可供选择。根据需求和要求,选择适合的插件是实现即时定位功能的关键。以下是几个

如何为WordPress插件添加微信小程序功能随着微信小程序的普及和流行,越来越多的网站和应用程序开始考虑将其与微信小程序进行集成。对于使用WordPress作为内容管理系统的网站来说,添加微信小程序功能可以为用户提供更便捷的访问体验和更多的功能选择。本文将介绍如何为WordPress插件添加微信小程序功能。步骤1:注册微信小程序账号首先,您需要在微信开放平

如何使用WordPress插件实现视频播放功能一、介绍视频在网站和博客中的应用越来越普遍。为了提供优质的用户体验,我们可以使用WordPress插件来实现视频播放功能。本文将介绍如何使用WordPress插件来实现视频播放功能,并提供代码示例。二、选择插件WordPress拥有众多视频播放插件可供选择。在选择插件时,我们需要考虑以下几个方面:兼容性:确保插件
