默认的只能保存jpg,gif,png的图片格式。
在dede/inc/inc_archives_funtions.php,只在dede 5.3中研究。5.1暂时没出来。
//获得文章body里的外部资源
function GetCurContent($body)
{
global $cfg_multi_site,$cfg_basehost,$cfg_basedir,$cfg_image_dir;
$cfg_uploaddir = $cfg_image_dir;
$htd = new DedeHttpDown();
$basehost = “http://”.$_SERVER[“HTTP_HOST”];
$img_array = array();
preg_match_all(“/src=[\”|’|\s]{0,}(http:\/\/([^>]*)\.(gif|jpg|png))/isU”,$body,$img_array);
$img_array = array_unique($img_array[1]);
$imgUrl = $cfg_uploaddir.”/”.MyDate(“ymd”,time());
$imgPath = $cfg_basedir.$imgUrl;
if(!is_dir($imgPath.”/”))
{
MkdirAll($imgPath,$GLOBALS[‘cfg_dir_purview’]);
CloseFtp();
}
$milliSecond = MyDate(“His”,time());
foreach($img_array as $key=>$value)
{
if(eregi($basehost,$value))
{
continue;
}
if($cfg_basehost!=$basehost && eregi($cfg_basehost,$value))
{
continue;
}
if(!eregi(“^http://”,$value))
{
continue;
}
$htd->OpenUrl($value);
$itype = $htd->GetHead(“content-type”);
$itype = substr($value,-4,4);
if(!eregi(“\.(jpg|gif|png)”,$itype))
{
if($itype==’image/gif’)
{
$itype = “.gif”;
}
else if($itype==’image/png’)
{
$itype = “.png”;
}
else
{
$itype = ‘.jpg’;
}
}
$milliSecondN = dd2char($milliSecond.mt_rand(1000,8000));
$value = trim($value);
$rndFileName = $imgPath.”/”.$milliSecondN.’-‘.$key.$itype;
$fileurl = $imgUrl.”/”.$milliSecondN.’-‘.$key.$itype;
$rs = $htd->SaveToBin($rndFileName);
if($rs)
{
$body = str_replace($value,$fileurl,$body);
@WaterImg($rndFileName,’down’);
}
}
$htd->Close();
return $body;
}
应该在此修改了。留个标记。以后研究。