打开 \include\extend.func.php 在最下面添加
/**
* 自定义图片字段调用图片地址
*
* @access public
* @param string $fieldname 字段名
* @param string $ftype 输出样式
* @return string
*/
if(!function_exists('GetImgUrl'))
{
function GetImgUrl($fieldname, $ftype = 1)
{
if($fieldname != '')
{
$dtp = new DedeTagParse();
$dtp->LoadSource($fieldname);
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:arclist typeid='1' row='14' titlelen='50' channelid='1' addfields='自定义字段名'}
[field:自定义字段名 function=GetImgUrl(@me)/]
{/dede:arclist}
列表页,自定义字段要勾选上这个才能在列表页使用

[field:自定义字段名 function=GetImgUrl(@me)/]
内容页
打开\templets\system\channel_article_image.htm 清空所有东西,只留下
[field:imgsrc/]
保存
{dede:field.自定义字段名/}
DedeCMS织梦工场QQ群
群号(23871657)
只适用于讨论dedecms二次开发相关话题,其他闲聊、广告、斗图、捣乱请自重自觉,谢谢合作!
不忘初心 、方得始终
DedeCMS织梦工场 - 致力于把最实用的DedeCms二次开发教程,DedeCms二次开发视频,DedeCms二次开发实例经验,分享给最需要的站长,希望每一位来访的站长都能有所收获!
如果您认为本网站的内容质量不错或者读后成功解决你心中的难题,觉得收获很大,那么不妨小额赞助一下,让我们有动力继续写出高质量的教程与更棒的程序教程。打赏记录
赞助方式
支付宝手机客户端扫描上面的二维码进行赞助
微信手机客户端扫描上面的二维码进行赞助