PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > CMS教程 > 齐博cms教程 > 正文

    齐博cms调用不同尺寸缩略图的方法

    作者:w634381967来源:网络浏览:时间:2020-09-30 00:07:50我要评论
    导读:齐博cms调用不同尺寸缩略图的方法,总一下分享给大家。
    首先打开/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);
    }
    }

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-107-1211-1.html
    相关热词搜索: