| 收藏本站 | 关于我们
首页 免费模板 收费模板 部分案例 分类模板 地方门户 二次修改 服务定制 酷站欣赏 设计学院 特效代码 字体下载
当前位置:首页 >> 二次修改
关于调用不同尺寸缩略图的方法
发布时间:2014-06-11 12:13:12
标签Tags:不同尺寸 缩略图
编辑发布:飞将军
首先打开/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);
}
}


点击率:1931
相关文章
网页特效代码
 服务流程 | 积分说明 | 使用说明 | 粤ICP备17004399号 电视直播 | QQ头像获取