我在项目中使用CK编辑器。我的要求是图片上传,源代码编辑器,字体样式等,并设置CK_Editor ADJUSTABLE的大小
为了在网页上显示编辑器,我搜索了Google,并且得到了类似
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
config.removePlugins = 'forms';
};
但这不起作用。请帮助我。请提供步骤
分步解决。
我将非常感激。
最佳答案
首先下载最新版本的ck编辑器,然后在config.js中添加以下行
config.extraPlugins = 'filebrowser';
config.filebrowserUploadUrl = 'Baseurl/controller_name/ckeditorImageUpload';
将以下功能添加到所需的控制器
/**
*
* This function used to upload images from ckeditor
*/
public function ckeditorImageUpload(){
$time = time();
//echo $_SERVER['DOCUMENT_ROOT'];exit;
//$url = '../../uploads/'.$time."_".$_FILES['upload']['name'];
$url = './images/ckeditor/uploads/' . $time . "_" . $_FILES['upload']['name'];
$furl = 'http' . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$fdata = explode('ckupload.php', $furl);
//extensive suitability check before doing anything with the file...
if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name']))) {
$message = "No file uploaded.";
} else if ($_FILES['upload']["size"] == 0) {
$message = "The file is of zero length.";
} else if (($_FILES['upload']["type"] != "image/pjpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png")) {
$message = "The image must be in either JPG or PNG format. Please upload a JPG or PNG instead.";
} else if (!is_uploaded_file($_FILES['upload']["tmp_name"])) {
$message = "You may be attempting to hack our server. We're on to you; expect a knock on the door sometime soon.";
} else {
$message = "";
echo $url;
//echo "<pre>";print_r($fdata);
//exit;
$move = @ move_uploaded_file($_FILES['upload']['tmp_name'], $url);
if (!$move) {
$message = "Error moving uploaded file. Check the script is granted Read/Write/Modify permissions.";
}
//$url = $fdata[0]."uploads/" . $time."_".$_FILES['upload']['name'];
$url = base_url() . "images/ckeditor/uploads/" . $time . "_" . $_FILES['upload']['name'];
}
$CKEditorFuncNum = $_GET['CKEditorFuncNum'];
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$message');</script>";
}
关于javascript - 如何在ckeditor中自定义工具并显示自定义工具,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30162474/