织梦CMS附件目录绑定域名后,替换成绑定域名访问
function SetBodyImg($body)
{
$img_array = array();
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$body,$img_array);
$img_array = array_unique($img_array[1]);
foreach($img_array as $key=>$value)
{
$okvalue = SetImgUrl($value);
$body = str_replace($value,$okvalue,$body);
}
return $body;
}
function SetImgUrl($picurl)
{
global $cfg_basehost,$cfg_addon_domainbind,$cfg_addon_domain;
if($cfg_addon_domainbind<>'Y'||empty($cfg_addon_domain)) return $picurl;
if(eregi($cfg_basehost,$picurl))
{
$picurl = str_replace('/uploads/','/',$picurl);
$picurl = str_replace($cfg_cmspath,'/',$picurl);
$picurl = str_replace($cfg_basehost,$cfg_addon_domain,$picurl);
return $picurl;
}
else if(eregi('defaultpic',$picurl))
{
$picurl = $cfg_addon_domain.'/nopic.gif';
return $picurl;
}
else if(eregi('http://',$picurl))
{
return $picurl;
}
else if(eregi('lit', $picurl))
{
$picurl = str_replace('_lit.','.',$picurl);
}
$picurl = $cfg_addon_domain.$picurl;
$picurl = str_replace('/uploads/','/',$picurl);
$picurl = str_replace($cfg_cmspath,'/',$picurl);
return $picurl;
}
实现dedecms图集单击图片翻页的功能
把下面的两个函数添加到DEDE去。后台设置DedeCMS系统配置参数:其它选项
设置
--------------------------------
附件目录是否绑定为指定的二级域名: 是
附件目录的二级域名: http://image.youdomain.com
-----------------------------------
文章内容
{dede:field.body function='SetBodyImg(@me)'/}
略缩图
[field:litpic function='SetImgUrl(@me)'/]
function SetBodyImg($body)
{
$img_array = array();
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$body,$img_array);
$img_array = array_unique($img_array[1]);
foreach($img_array as $key=>$value)
{
$okvalue = SetImgUrl($value);
$body = str_replace($value,$okvalue,$body);
}
return $body;
}
function SetImgUrl($picurl)
{
global $cfg_basehost,$cfg_addon_domainbind,$cfg_addon_domain;
if($cfg_addon_domainbind<>'Y'||empty($cfg_addon_domain)) return $picurl;
if(eregi($cfg_basehost,$picurl))
{
$picurl = str_replace('/uploads/','/',$picurl);
$picurl = str_replace($cfg_cmspath,'/',$picurl);
$picurl = str_replace($cfg_basehost,$cfg_addon_domain,$picurl);
return $picurl;
}
else if(eregi('defaultpic',$picurl))
{
$picurl = $cfg_addon_domain.'/nopic.gif';
return $picurl;
}
else if(eregi('http://',$picurl))
{
return $picurl;
}
else if(eregi('lit', $picurl))
{
$picurl = str_replace('_lit.','.',$picurl);
}
$picurl = $cfg_addon_domain.$picurl;
$picurl = str_replace('/uploads/','/',$picurl);
$picurl = str_replace($cfg_cmspath,'/',$picurl);
return $picurl;
}
实现dedecms图集单击图片翻页的功能