dedecms

dede中添加新的内容模型图片时,图片所保存的字段含有{dede:img}等多余信息,可以给extend.func.php添加:

function clearimgurl($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;
}
}

调用方式为{dede:field.字段名 function='clearimgurl(@me,0)'/}

posted @ 2017-09-06 17:20  一切如旧  阅读(213)  评论(0)    收藏  举报