帝国CMS内容字段域名替换函数
帝国CMS给内容字段图片加链接函数,第一个参数是内容,第2个参数是替换域名。functiondomainReplace($text,$url){$pattern="/<[img|IMG].*?src=[&#39;|"](.*?(?:[.jpg|.jpeg|.png|.gif|.bmp]))[&#39;|"].*?[/]?>/";$text……
帝国CMS给内容字段图片加链接函数,第一个参数是内容,第2个参数是替换域名。
functiondomainReplace($text,$url){$pattern="/<[img|IMG].*?src=['|"](.*?(?:[.jpg|.jpeg|.png|.gif|.bmp]))['|"].*?[/]?>/";$text=stripSlashes($text);returnpreg_replace_callback($pattern,function($matches)use($url){if('/'!==substr($matches[1],0,1)&&'http'!==substr($matches[1],0,4)){returnstr_replace($matches[1],$url.$matches[1],$matches[0]);}return$matches[0];},$text);}
升级版
functiondomainReplace($content='',$url='',$s=0){$pattern="/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg|.png]))["|'].*?[/]?>/";returnpreg_replace_callback($pattern,function($matches)use($url){if(1===$s&&false!==stristr($matches[0],$url)){returnstr_replace($url,'',$matches[0]);}elseif(0===$s&&'/'!==substr($matches[1],0,1)&&'http'!==substr($matches[1],0,4)){returnstr_replace($matches[1],$url.$matches[1],$matches[0]);}else{return$matches[0];}},$content);}
- 上一篇
国CMS灵动标签调用标题属性加粗颜色失效
帝国CMS灵动标签调用标题属性加粗颜色失效的处理方法!实现方法如下:把标题的灵动标签改成如下代码:<?=DoTitleFont($bqr[titlefont],$bqr[title])?>如果加上截取字符就是如下代码:<?=DoTitleFont($bqr[titlefont],esub($
- 下一篇
帝国cms二次开发常用变量、模板和函数大全免费分享给大家
1、系统模板所在的位置:采集字段模板e/data/html/cjhtml.txt前台字段表单模板e/data/html/qfhtml.txt后台字段表单模板e/data/html/sysfhtml.txt栏目字段表单模板e/data/html/classfhtml.txt会员字段表单模板e/data/ht