当前位置: 首页> 游戏> 手游 > 营销策划公司介绍_上海内贸网站建设_樱花bt引擎_如何制作付费视频网站

营销策划公司介绍_上海内贸网站建设_樱花bt引擎_如何制作付费视频网站

时间:2025/7/9 8:10:19来源:https://blog.csdn.net/qiangzi8844/article/details/144646204 浏览次数:0次
营销策划公司介绍_上海内贸网站建设_樱花bt引擎_如何制作付费视频网站

帝国CMS背景可自定义,可单独背景也可以随机背景,此插件根帝国cms官方论坛帖子改的,增加了生成图片后写入数据库,笔者的古诗词网 www.gushichi.com 也是这样设置的。

效果图

将下面的代码插入到/e/class/userfun.php中增加如下函数

单独背景代码

//自动生成图片
function Cyimg($classid,$id,$width='512',$height='340',$bg='',$path='d/file/titlepic/'){global $dbtbpre,$empire,$class_r,$public_r;$bg = ECMS_PATH.'/bazhepu/images/titlepicbg.png';//背景图片存放的路径  指定一张图片$tbname = $class_r[$classid]['tbname'];$r=$empire->fetch1("select * from {$dbtbpre}ecms_{$tbname} where id='$id' limit 1");$mycr=GetPathname($class_r[$r['classid']]['classpath']);//栏目目录$classpath=$mycr[0];//获取栏目目录$path = $path.$classpath.$r['id'].'.png';//保存的图片名称$file = ECMS_PATH.$path;//图片的绝对地址if(!file_exists($file)){//判断图片是否存在    测试的时候把!去掉   正式使用时加上就可以了$font = ECMS_PATH."/bazhepu/font/PingFangMedium.ttf";//你需要的字体路径$myImage=imagecreatefrompng($bg);//背景图片$blue=imagecolorallocate($myImage, 210, 95, 50);//设置字体颜色$fontBox = imagettfbbox(55, 0, $font ,$r['title']);//获取文字所需的尺寸大小$width = ceil(($width - $fontBox[2]) / 2) + 20;//计算文字所需宽度  居中   后面加的数字表示偏移多少$height = ceil(($height - $fontBox[1] - $fontBox[7]) / 2) - 35;//计算文字所需高度 居中 后面加的数字表示偏移多少imagettftext($myImage, 48, 0, $width, $height, $blue, $font, $r['title']); //生成图片imagepng($myImage,$file); //保存图片imagedestroy($myImage);//释放内存// 更新数据$empire->query("update {$dbtbpre}ecms_{$tbname} set titlepic = '".$path."'  where id= '$id'");}return $public_r['newsurl'].$path;//返回图片路径
}

随机背景代码

function Cyimg($classid,$id,$width='512',$height='340',$bg='',$path='d/file/titlepic/'){global $dbtbpre,$empire,$class_r,$public_r;$bgnum = rand(1,9);//随机数字图片名字$bg = ECMS_PATH.'/bazhepu/images/'.$bgnum.'.png';//背景图片存放的路径  随机多张图片$tbname = $class_r[$classid]['tbname'];$r=$empire->fetch1("select * from {$dbtbpre}ecms_{$tbname} where id='$id' limit 1");$mycr=GetPathname($class_r[$r['classid']]['classpath']);//栏目目录$classpath=$mycr[0];//获取栏目目录$path = $path.$classpath.$r['id'].'.png';//保存的图片名称$file = ECMS_PATH.$path;//图片的绝对地址if(!file_exists($file)){//判断图片是否存在    测试的时候把!去掉   正式使用时加上就可以了$font = ECMS_PATH."/bazhepu/font/PingFangMedium.ttf";//你需要的字体路径$myImage=imagecreatefrompng($bg);//背景图片$blue=imagecolorallocate($myImage, 210, 95, 50);//设置字体颜色$fontBox = imagettfbbox(55, 0, $font ,$r['title']);//获取文字所需的尺寸大小$width = ceil(($width - $fontBox[2]) / 2) + 20;//计算文字所需宽度  居中   后面加的数字表示偏移多少$height = ceil(($height - $fontBox[1] - $fontBox[7]) / 2) - 35;//计算文字所需高度 居中 后面加的数字表示偏移多少imagettftext($myImage, 48, 0, $width, $height, $blue, $font, $r['title']); //生成图片imagepng($myImage,$file); //保存图片imagedestroy($myImage);//释放内存// 更新数据$empire->query("update {$dbtbpre}ecms_{$tbname} set titlepic = '".$path."'  where id= '$id'");}return $public_r['newsurl'].$path;//返回图片路径
}

内容页调用代码

<img src="<?=Cyimg($navinfor['classid'],$navinfor['id'])?>" />
关键字:营销策划公司介绍_上海内贸网站建设_樱花bt引擎_如何制作付费视频网站

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: