為dedecms3.0.1采集器增加縮圖功能_DedeCms教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
需要更改源文件,而且未經過嚴格驗證,只作交流用。
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,
$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,
相關DedeCms教程:
- Dedecms生成百度地圖圖文教程
- 織夢dedecms生成下拉式友情鏈接列表
- DEDECMS使用拼音首字母做欄目名稱
- 織夢DEDECMS站群增強版 DedeCMS搭建站群首選
- DedeCMS Error:Tag disabled:php錯誤的完整處理方法
- dedecms編碼轉換方法 gbk轉UTF-8,UTF-8轉GBK
- 防XSS,sql注射,代碼執行,文件包含的通用代碼
- DedeCms教程:優化DedeCMS搜索結果
- DedeCms教程:Linux+Apache+PHP+MySQL服務器環境(CentOS篇)
- DedeCms教程:LuManager服務器管理軟件安裝DEDECMS軟件
- DedeCms教程:Ubuntu/Debian上安裝 PHP 5.3, Nginx 和 PHP-fpm
- DedeCms教程:windows server 2003 php 環境搭建