I ran to csdn to ask about the discuz plug-in. I believe in the strength of the organization! This plug-in is like a post. displaying thumbnails in the post list is a style I like very much and applies to X3.0. However, for the client, I can only use X2.5, this plug-in does not work in X2.5 and cannot generate thumbnails. I just want to modify the code so that it can work in X2.5 environment for my own use and is not commercially available.
In X3.0, a folder for storing thumbnails is generated, which contains thumbnails. However, this folder was not found in Section 2.5, so I felt a problem occurred during build.
Below is the code for the thumbbuilder. class. php file. please analyze why tiebalist folder is not generated under data/attachment.
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. '. jp G') $ images [] = array ('aid '=> $ aid, 'thumbfile' => $ fullurl.20.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) {define target=#path.20.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 ); // The cover width is not limited} $ thumb-> save ($ target);} catch (Exception $ oEx) {// capture exceptions that may be thrown when a thumbnail is generated to prevent medium Disconnect 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 ;}}?>
Reply to discussion (solution)
The content in buildthumb. inc. php may also be useful.
$ Value) {$ position = ($ value ['special '] = 2 )? ; // The first post of the subject is on the second floor. The Reply starts from the second floor. $ firstpost = C: t ('forum _ Post')-> fetch_all_by_tid_position ('tid: '. $ value ['tid'], $ value ['tid'], $ position); if (count ($ firstpost)> 0 & $ firstpost [0] ['invisable']> = 0) {$ post = & $ firstpost [0]; $ message = messagecutstr ($ post ['message'], $ messagelength); $ tiebalist [$ key] =''. $ Message .'
'; $ 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]. ='
'; Foreach ($ imagelist as $ ii => $ image) {$ attach = $ attachs [$ image ['aid']; $ forumimg = ($ attach ['remote']? $ _ G ['setting'] ['ftp '] ['attachurl']: $ _ G ['setting'] ['attachurl']). 'forum /'. $ attach ['attachment']; $ tiebalist [$ key]. ='
';} $ Tiebalist [$ key]. ='
'; $ Tiebalist [$ key]. ='
Hide | view Post | turn left | turn right
';}}}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 ='
'; $ Echo. ='