Dedecms 模板中心

您现在的位置: 首页 > 教程文档 > 织梦技巧 >

为dedecms3.0.1采集器增加缩图功能

来源:未知 发布时间:2016-06-04热度:
需要更改源文件,而且未经过严格验证,只作交流用。1:打开治理目录中 action_co_export.php。在开始部分加上require_once(dirname(__FILE__)./../include/inc_photograph.php);在68行下增加/**********缩图生成开始****************************************...

需要更改源文件,而且未经过严格验证,只作交流用。 1:打开治理目录中 action_co_export.php。 在开始部分加上 require_once(dirname(__FILE__)."/../include/inc_photograph.php"); 在68行下增加/**********缩图生成开始**************************************************/ $litpic="";$DBlipic=""; if(preg_match("~(/upimg. ?)(\" ?) ~",$fields[$body_sel],$match)){ $litpic=$match[1];$imagesdir=$cfg_basedir.$litpic; $sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png"); 
$savepath = $ddcfg_image_dir.str_replace("-","",GetDateMk($pubdate)); CreateDir($savepath);$rname = GetPinyin($title,1,0); $rndname = substr($rname,strlen($rname)-6,6).$typeid; $fullUrl = $savepath."/".$rndname; $spdd = 1; while(true){ if(!file_exists($cfg_basedir.$fullUrl."-".$spdd.".jpg")||$spdd>1000) break; $spdd ; } $fullUrl = $fullUrl."-".$spdd.".jpg";$limg=$cfg_basedir.$fullUrl; copy($imagesdir,$limg); //@unlink($litpic);if(ImageResize($limg,200,120)){ $DBlipic=$fullUrl; } } 
/*********************缩图生成结束*************************/ 这里我用$cfg_basedir作为路径未成功,最后使用了硬代码。 if(ImageResize($limg,200,120))这里的200,和120是你要生成的缩图的尺寸。 2:在文件中找到 $inQuery = "INSERT INTO dede_archives( typeid,typeid2,sortrank,iscommend,ismake,channel,arcrank,click,title,color,writer,source,litpic,pubdate,senddate,adminID,memberID,description,keywords) VALUES ('$typeid','$typeid2','$sortrank','$iscommend','$ismake','1','$arcrank','0','$title','$color','$writer','$source','','$pubdate','$senddate','$adminID','0','$description','$keywords');"; 改为 $inQuery = "INSERT INTO dede_archives( typeid,typeid2,sortrank,iscommend,ismake,channel,arcrank,click,title,color,writer,source,litpic,pubdate,senddate,adminID,memberID,description,keywords) VALUES ('$typeid','$typeid2','$sortrank','$iscommend','$ismake','1','$arcrank','0','$title','$color','$writer','$source','$DBlipic','$pubdate','$senddate','$adminID','0','$description','$keywords');"; 
就是增加$DBlipic变量入表。 3:打开include文件夹下的inc_photograph.php文件 将 function ImageResize($srcFile,$toW,$toH) { $toFile = $srcFile; $data = GetImageSize($srcFile,&$info);switch ($data[2]) { case 1:

    责任编辑:好织梦