
用帝国做的商城系统,上传了很多产品图片,后来要求把缩略图改小,很伤脑筋,那么帝国cms6.0如何批量修改标题缩略图[titlepic]呢?
以下为修改方法:
一、首先,在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格式
!<a href='<font>javascript:</font>go(-1);'>返回</a>";
             exit();
         }
         $im = ImageCreateFromGIF($srcFile);
         break;
     case 2:
         if (!function_exists("imagecreatefromjpeg")) {
             Echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图
片!<a href='<font>javascript:</font>go(-1);'>返回</a>";
             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},大约在最后几行“选中全部
</td></tr>”的后面添加以下代码:
 <tr bgcolor="#fff">
   <td height="25" colspan="8">
     <div align="right">缩略图宽:
       <input name="pwidth" type="text" value="120" width="60">缩略图高:
       <input name="pheight" type="text" value="120" width="60">
       <input type="submit" name="Submit355" value="修改缩略图" onClick="document.listform.enews.value='Titlepic_all';"></div></td>
 </tr> 
其中,图宽和图稿的默认值可按自己的情况设定,设定好后,以后操作更方便。
三、在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'=>'操作成功!',
wordpress如何直接调用特色图片(has_post_thumbnail)
标签: class, CMS网站, titlepic, 修改, 缩略图
上面是“帝国cms6.0如何批量修改标题缩略图[titlepic]”的全面内容,想了解更多关于 帝国cms 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_1113.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

 宝塔Linux面板部署SSL直接闪退重新加载面板解决方法
 毒蘑菇显卡测试官网:一款专门用于评估显卡图形处理能力的工具
 Github中国全球用户排名查询、仓库Star排名