POST TIME:2017-11-13 00:46
上一篇回顧
經(jīng)過努力和摸索上次終于完成了dedecms和百度編輯器(Ueditor)的整合,只是功能不是那么完美。這次主要寫的就是dedecms和ueditor整合優(yōu)化之圖片上傳路徑問題
dedecms整合ueditor后圖片上傳路徑問題
如果按前篇dedecms整合百度編輯器(Ueditor)一(基本整合)整合后也是可以使用圖片上傳,ueditor在線抓圖的,只是圖片會(huì)保存到"\include\Ueditor\php\upload"這個(gè)目錄下,為了統(tǒng)一想把ueditor編輯器所有上傳、遠(yuǎn)程抓取的圖片都保存到"\uploads\allimg\bdimg"
優(yōu)化dedecms整合ueditor后圖片上傳路徑
找到:,imagePath:URL + "php/"
替換為:,imagePath:"/"
找到:,scrawlPath:URL+"php/"
替換為:,scrawlPath:"/"
找到:URL + "php/"
替換為:,filePath:"/"
找到:,catcherPath:URL + "php/"
替換為:,catcherPath:"/"
找到:,imageManagerPath:URL + "php/"
替換為:,imageManagerPath:"/"
找到:,snapscreenPath: URL + "php/"
替換為:,snapscreenPath: "/"
找到:
$pathStr=$this->config["savePath"];
if(strrchr($pathStr,"/")!="/"){
$pathStr.="/";
}
$pathStr.=date("Ymd");
if(!file_exists($pathStr)){
if(!mkdir($pathStr,0777,true)){
returnfalse;
}
}
return$pathStr;替換為:
$pathStr=$this->config["savePath"];
$pathStr=str_replace('\\','/',$pathStr);
if(strrchr($pathStr,"/")=="/"){
$pathStr=substr($pathStr,0,-1);
}
$dirpath=explode('/',$pathStr.date('/Ym'));//通過斜杠分割
$dir='';
for($i=0;$i<count($dirpath);$i++)
{
if($i!=count($dirpath))
{
$dir.=$dirpath[$i].'/';
}
if(!file_exists($dir))
{
if(!mkdir($dir,0777,true))returnfalse;
}
}
if(strrchr($dir,"/")=="/"){
$dir=substr($dir,0,-1);
}
/*$pathStr=$this->config["savePath"];
if(strrchr($pathStr,"/")!="/"){
$pathStr.="/";
}
$pathStr.=date("Ymd");
if(!file_exists($pathStr)){
if(!mkdir($pathStr,0777,true)){
returnfalse;
}
}*/
return$dir;找到:"savePath" => "upload/" ,
替換為:"savePath" => "../../../uploads/allimg/bdimg" ,
找到:echo "{'url':'" . $info["url"] . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";
替換為:echo "{'url':'" . str_replace('../','',$info[ "url" ]) . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";
修改說明:第一處替換就是修改圖片保存路徑的,第二處替換是因?yàn)檫@里用的是相對(duì)路徑要把../替換掉,返回給編輯器后就是絕對(duì)路徑了。如這里上傳了一張圖片1.jpg,他的路徑就是../../../uploads/allimg/bdimg/201220/1.jpg,結(jié)合前面修改editor_config.js的,imagePath:"/"總終路徑就是/../../../uploads/allimg/bdimg/201220/1.jpg,所有這里替換一下。以下的幾個(gè)文件修改跟這個(gè)是類似的。
找到:"savePath" => "upload/" ,
替換為:"savePath" => "../../../uploads/allimg/bdimg" ,
找到://創(chuàng)建保存位置$savePath = $config[ 'savePath' ];if ( !file_exists( $savePath ) ) {mkdir( "$savePath" , 0777 );}
替換為://創(chuàng)建保存位置
$savePath = $config[ 'savePath' ];
$dirpath = explode('/',$savePath.date('/Ym'));//通過斜杠分割
$savePath = '';
for($i=0;$i
{
if($i != count($dirpath))
{
$savePath .= $dirpath[$i].'/';
}
if(!file_exists($savePath))
{
if(!mkdir($savePath,0777,true))return false;
}
}
找到:echo "{'url':'" . implode( "ue_separate_ue" , $tmpNames ) . "','tip':'遠(yuǎn)程圖片抓取成功!','srcUrl':'" . $uri . "'}";
替換為:echo "{'url':'" . implode( "ue_separate_ue", str_replace('../', '', $tmpNames)) . "','tip':'遠(yuǎn)程圖片抓取成功!','srcUrl':'" . $uri . "'}";
一般編輯用的最多就是圖片上傳和遠(yuǎn)程抓圖這兩個(gè)功能了,其他如:涂鴉、截屏啥的可以自己做下修改就行了,修改方法跟上面的類似;ueditor那個(gè)圖片在線管理目前來看沒什么很大的用處。dedecms整合百度編輯器(Ueditor)
下一篇預(yù)告:dedecms整合百度編輯器(Ueditor)三(織夢使用Ueditor圖片水印問題)
如有問題可以聯(lián)系QQ:2655101040,一家一起討論
本文來源:genban.org
