最新公告
  • 欢迎您光临 我爱模板网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境! 立即加入钻石VIP
  • 帝国cms6.0批量修改标题缩略图【titlepic】

    正文概述 管理员   2025-09-05   4

    帝国做的商城系统,上传了很多产品图片,后来要求把缩略图改小,很伤脑筋,结果找到上面的帖子,但怎么搞也不行,可能那不是针对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格式  
    
    !<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},大约在最后几行“选中全部 ”的后面添加以下代码:

    <tr bgcolor="#FFFFFF">
    <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'=>'操作成功!',

    我爱模板网 » 帝国cms6.0批量修改标题缩略图【titlepic】

    发表评论

    如需帝国cms功能定制以及二次开发请联系我们

    联系作者
    script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?587cc1e5c052b5b0ce99533beff13c96"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();

    请选择支付方式

    ×
    支付宝支付
    余额支付
    ×
    微信扫码支付 0 元