{dede:field.body runphp=yes}
$string = @me;
$result = preg_replace("/]+>/i","",$string);
@me = $result;
{/dede:field.body}
{dede:field.body runphp=yes}
$string = @me;
preg_match_all("/
]*)s*src=('|")([^'"]+)('|")/",$string,$matches);
$imgsrc_arr = array_unique($matches[3]);
foreach($imgsrc_arr as $imgsrc)
{
$result .= "
";
}
@me = $result;
{/dede:field.body}
通过上述代码,我们可以分别调用文章中的文字和图片部分。第一段代码用于提取并显示文章中的纯文本内容,而第二段代码则专门用于提取并展示文章中的所有图片。 首先,
对于内容文字的调用,我们使用了正则表达式来移除所有的图片标签,只留下纯文本。
其次,
针对内容图片的调用,我们采用了不同的策略。这里,我们利用正则表达式匹配所有的