首先打開/inc/check.postarticle.php 200行左右
$Newpicpath=ROOT_PATH."$webdb[updir]/$smallpic";
$picWidth>500 && $picWidth=300;
$picWidth<50 && $picWidth=300;
$picHeight>500 && $picHeight=225;
$picHeight<50 && $picHeight=225;
gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]",$Newpicpath,$picWidth?$picWidth:300,$picHeight?$picHeight:225,$webdb[autoCutSmallPic]?array('fix'=>1):'');
//多生成一張3:4的圖片,方便標簽調用
gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]","$Newpicpath.jpg",$picHeight?$picHeight:225,$picWidth?$picWidth:300,$webdb[autoCutSmallPic]?array('fix'=>1):'');
//多生成一張1:1的圖片,方便標簽調用
gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]","$Newpicpath.jpg.jpg",$picWidth?$picWidth:300,$picWidth?$picWidth:300,$webdb[autoCutSmallPic]?array('fix'=>1):'');
if( file_exists($Newpicpath) )
{
$postdb[picurl]=$smallpic;
這是默認的,齊博會生成3個縮略圖,尺寸自己可以定義。因為我只需兩個尺寸縮略圖,一個大的320*235,一個小的130*90的,所以把生成縮略圖的代碼去掉一個,為了區分大圖和小圖的調用,我把大尺寸的圖后綴定義為.gif。
我不需要等比例縮放,就把縮放的代碼注釋掉了,不過如果不注釋掉好像生成縮略圖有問題,我也不懂,還請高手驗證下
同時生成縮略圖的代碼也做了修改
修改完畢的代碼如下:
$Newpicpath=ROOT_PATH."$webdb[updir]/$smallpic";
//$picWidth>500 && $picWidth=300;
//$picWidth<50 && $picWidth=300;
//$picHeight>500 && $picHeight=225;
//$picHeight<50 && $picHeight=225;
gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]",$Newpicpath,130,90,$webdb[autoCutSmallPic]?array('fix'=>1):'');
//多生成一張大尺寸的圖片,方便幻燈片調用
gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]","$Newpicpath.gif",320,235,$webdb[autoCutSmallPic]?array('fix'=>1):'');
if( file_exists($Newpicpath) )
{
$postdb[picurl]=$smallpic;
這樣修改完畢后,就會生成不同尺寸縮略圖,那么在打開/inc/label_funcation.php,90行左右
//自定義幻燈片接口
if($RollStyleType&&is_file(ROOT_PATH."template/default/rollpic/$RollStyleType") ){
foreach($picurl AS $key=>$value){
$picurl[$key]=addslashes($picurl[$key]).".gif";//這里是幻燈片調用生成的大圖
$picalt[$key]=addslashes($picalt[$key]);
$piclink[$key]=urlencode($piclink[$key]);
修改幻燈片調用的圖片名稱,貌似是$img這個變量,我在后面多加個.gif,就是注釋那個位置,如果不懂PHP,這個書寫格式是真心想不出,試了無數個書寫方法,哎
現在,發布文章,看看縮略圖的效果吧
如果是圖片模型,還需要修改/inc/check.postarticle.php,135行左右
源文件:
if(!$postdb[picurl]){
copy(ROOT_PATH."$webdb[updir]/$value",ROOT_PATH."$webdb[updir]/{$value}.jpg");
$postdb[picurl]="{$value}.jpg";
}
move_attachment($lfjuid,tempdir($value),"photo/$fid");
if(is_file(ROOT_PATH."$webdb[updir]/photo/$fid/".basename($value))){
$post_db[photourl][url][$key]="photo/$fid/".basename($value);
}
}
修改后的代碼:
if(!$postdb[picurl]){
copy(ROOT_PATH."$webdb[updir]/$value",ROOT_PATH."$webdb[updir]/{$value}.jpg");
$postdb[picurl]="{$value}.jpg";
}
$str=str_replace(other,"photo/$fid",$value);
gdpic(ROOT_PATH."$webdb[updir]/$value",ROOT_PATH."$webdb[updir]/{$str}.thumbnails.jpg",100,75,$webdb[autoCutSmallPic]?array('fix'=>1):'');//整個圖組每張圖片生成固定大小縮略圖,加快加載速度
$str=str_replace(other,"photo/$fid",$value);
gdpic(ROOT_PATH."$webdb[updir]/{$value}.jpg",ROOT_PATH."$webdb[updir]/{$str}.jpg.gif",320,235,$webdb[autoCutSmallPic]?array('fix'=>1):'');//第一張圖片生成固定大小縮略圖
move_attachment($lfjuid,tempdir($value),"photo/$fid");
if(is_file(ROOT_PATH."$webdb[updir]/photo/$fid/".basename($value))){
$post_db[photourl][url][$key]="photo/$fid/".basename($value);
}
}
新聞熱點
疑難解答