本文整理自网络,侵删。
一、实现方法1)创建自定义函数
打开 /include/extend.func.php 文件(注:这个文件就是系统预留的自定义函数接口文件,主要用于二次开发用的。如果你是老版本,默认没有这个文件,自己创建一个PHP文件即可),在最下面的?>上一行加入以下函数代码:
代码如下:
/****************
function GetOneImgUrl
@@ 功能:读取自定义字段图片地址
*****************/
function GetOneImgUrl($img,$ftype=1){
if($img <> ''){
$dtp = new DedeTagParse();
$dtp->LoadSource($img);
if(is_array($dtp->CTags)){
foreach($dtp->CTags as $ctag){
if($ctag->GetName()=='img'){
$width = $ctag->GetAtt(‘width');
$height = $ctag->GetAtt(‘height');
$imgurl = trim($ctag->GetInnerText());
$img = '';
if($imgurl != ''){
if($ftype==1){
$img .= $imgurl;
}
else{
$img .= ‘<img src=''‘.$imgurl.''' width=''‘.$width.''' height=''‘.$height.''' />';
}
}
}
}
}
$dtp->Clear();
return $img;
}
}
/****************
function GetOneImgUrl
@@ 功能:读取自定义字段图片地址
*****************/
function GetOneImgUrl($img,$ftype=1){
if($img <> ''){
$dtp = new DedeTagParse();
$dtp->LoadSource($img);
if(is_array($dtp->CTags)){
foreach($dtp->CTags as $ctag){
if($ctag->GetName()=='img'){
$width = $ctag->GetAtt(‘width');
$height = $ctag->GetAtt(‘height');
$imgurl = trim($ctag->GetInnerText());
$img = '';
if($imgurl != ''){
if($ftype==1){
$img .= $imgurl;
}
else{
$img .= ‘<img src=''‘.$imgurl.''' width=''‘.$width.''' height=''‘.$height.''' />';
}
}
}
}
}
$dtp->Clear();
return $img;
}
}
相关阅读 >>
织梦DedeCMS站点data目录位置变动调整验证码不显示的解决办法
powereasy siteweaver 6.8转换为dedecms5.7的方法
dedecms织梦模板用array调用多个自定义字段并判断的方法
更多相关阅读请进入《织梦DedeCMS》频道 >>
相关推荐
评论
管理员已关闭评论功能...
- 欢迎访问木庄网络博客
- 可复制:代码框内的文字。
- 方法:Ctrl+C。