用帝國做的商城系統,上傳了很多產品圖片,后來要求把縮略圖改小,很傷腦筋,結果找到上面的帖子,但怎么搞也不行,可能那不是針對6.0.所有自己加以修改終于成功?。?!
以下為修改方法:
一、首先,在t_functions.php中添加一下兩個函數
function?Titlepic_all?($id,?$classid,?$userid,?$username,?$pwidth,?$pheight) ????{ ??????global?$empire,$class_r,$class_zr,$dbtbpre,$keys; ??????$count?=?count?($id); ??????if?(!$count) ??????{ ????????printerror?('Noteditpic',?'history.go(-1)'); ??????} ??????for?($i?=?0;?($i?$count);?++$i) ??????{ ????????$r?=?$empire->fetch1?('select?*?from?phome_ecms_'.$class_r[$classid][tbname].'?where?id='.$id[$i].'?and?titlepic<>""'); ????????if(!emptyempty($r[id])){ ????????????ImageResize("../../".$r[titlepic],$pwidth,$pheight,"../../".$r[titlepic]); ???????????? ????????????} ??????????} ??printerror?('TitlepicAllSuccess',?$_SERVER['HTTP_REFERER']); ????} ??Function?ImageResize($srcFile,$toW,$toH,$toFile="")? ??{ ????global?$keys; ????if($toFile==""){?$toFile?=?substr($srcFile,0,-4)."small".substr($srcFile,-4);?} ????$info?=?""; ????$data?=?GetImageSize($srcFile,$info); ????switch?($data[2])? ????{ ????case?1: ??????if(!function_exists("imagecreatefromgif")){ ??????echo?"你的GD庫不能使用GIF格式的圖片,請使用Jpeg或PNG格式 ?!javascript:go(-1);'>返回"; ??????exit(); ??????} ??????$im?=?ImageCreateFromGIF($srcFile); ??????break; ????case?2: ??????if(!function_exists("imagecreatefromjpeg")){ ??????Echo?"你的GD庫不能使用jpeg格式的圖片,請使用其它格式的圖 ?片!javascript:go(-1);'>返回"; ??????Exit(); ??????} ??????$im?=?ImageCreateFromJpeg($srcFile);??? ??????break; ????case?3: ??????$im?=?ImageCreateFromPNG($srcFile);??? ??????break; ??} ??$srcW?=?ImageSX($im); ??$srcH?=?ImageSY($im); ??$keys=?0; ??if?(($srcW>$toW)?or?($srH>$toH)){ ??if(($srcW/$toW)>=($srcH/$toH)){ ??????????????????$temp_height=$toH; ??????????????????$temp_width=$srcW/($srcH/$toH); ??????????????????$src_X=Abs(($toW-$temp_width)/2); ??????????????????$src_Y=0; ??????????} ??????????else{ ??????????????????$temp_width=$toW; ??????????????????$temp_height=$srcH/($srcW/$toW); ??????????????????$src_X=0; ??????????????????$src_Y=Abs(($toH-$temp_height)/2); ??????????????????} ??????????$temp_img=ImageCreateTrueColor($temp_width,$temp_height); ??????????imagecopyResampled($temp_img,$im,0,0,0,0,$temp_width,$temp_height,$srcW,$srcH); ??????????$ni=ImageCreateTrueColor($toW,$toH); ??????????imagecopyResampled($ni,$temp_img,0,0,$src_X,$src_Y,$toW,$toH,$toW,$toH); ????if(Function_exists('imagejpeg'))?ImageJpeg($ni,$toFile); ????else?ImagePNG($ni,$toFile); ????ImageDestroy($ni); ??$keys=?1; ??} ??ImageDestroy($im); ??}??
二、修改 e/admin/ListNews.php{還有個頁面:e/admin/ListAllInfo.php},大約在最后幾行“選中全部 ”的后面添加以下代碼:
縮略圖寬: 縮略圖高:
其中,圖寬和圖稿的默認值可按自己的情況設定,設定好后,以后操作更方便。
三、在e/admin/ecmsinfo.php中添加如下代碼:
//批量加標題圖片elseif($enews=="Titlepic_all"){? ?? ???$id=$_POST['id'];? ?? ???$classid=$_POST['classid'];? ?? ???$bclassid=$_POST['bclassid'];? ?? ???$pwidth=$_POST['pwidth'];? ?? ???$pheight=$_POST['pheight'];Titlepic_all($id,$classid,$logininid,$loginin,$pwidth,$pheight);}
四、函數中用到“ printerror ('Noteditpic', 'history.go(-1)');”等操作提示,這個提示可加在e/data/language/gb/pub/message.php;當然這一步不加也不影響操作
在message.php 后面加:
? ? ? ? 'Noteditpic'=>'沒有選擇!',? ? ? ? 'TitlepicAllSuccess'=>'操作成功!',
新聞熱點
疑難解答