百度MIP改造自定义正文替换函数,把编辑器内的img a标签等替换为mip标准格式。
1、打开/e/class/userfun.php添加处理函数:
functionNewsTextReplace($add){$add['newstext']=preg_replace('/<img.*?src="(.*?)".*?>/is','<mip-imgalt=""src="$1"></mip-img>',stripslashes($add['newstext']));$add['newstext']=preg_replace('/<a.*?href="(.*?)".*?<\/a>/is','<adata-type="mip"data-title="'.$add['title'].'"href="$1"></a>',$add['newstext']);$add['newstext']=addslashes($add['newstext']);return$add;}
2、打开/e/action/show.php搜索 $GLOBALS['navclassid'] = $r['classid'];
在前面添加代码:
$r=NewsTextReplace($r);