dede调用文章内容时不调用内容里的图片

admin2023-01-181366

调用文章内容不调用图片

<div>
{dede:field.body runphp=yes}
$string = @me;
$result = preg_replace("/<\s{0,}img[^>]+>/i",'',$string);
@me = $result;
{/dede:field.body}
</div>

调用文章图片不调用文字

div>
{dede:field.body runphp=yes}
$string = @me;
preg_match_all("/<img([^>]*)\s*src=('|\")([^'\"]+)('|\")/",$string,$matches);
$imgsrc_arr = array_unique($matches[3]);
foreach($imgsrc_arr as $imgsrc)
{
$result .= "<li><img class=\"img\" src=\"$imgsrc\"></li>\n";
}
@me = $result;
{/dede:field.body}
</div>

调用文章图片不调用文字还有一种方法,dede在首页调用文章页的多张图片,该方法让模版更加简介,但要修改dede默认文件,添加函数。如果想把dede的程序从老版本更换成最新的版本,就要注意了,仅仅把模版文件换过去是不够的,相对麻烦点。

网友评论