Created
August 17, 2018 11:06
-
-
Save BadAllOff/58c5cfbeb6f550dd346814e211b2f565 to your computer and use it in GitHub Desktop.
CKEditor config.js file to upload images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* BASE PATH */ | |
CKEDITOR.editorConfig = function(config) { | |
config.filebrowserBrowseUrl = "/ckeditor/attachment_files"; | |
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files"; | |
config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files"; | |
config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures"; | |
config.filebrowserImageBrowseUrl = "/ckeditor/pictures"; | |
config.filebrowserImageUploadUrl = "/ckeditor/pictures"; | |
config.filebrowserUploadUrl = "/ckeditor/attachment_files"; | |
config.filebrowserParams = function() { | |
var csrf_param, csrf_token, i, meta, metas, params; | |
csrf_token = void 0; | |
csrf_param = void 0; | |
meta = void 0; | |
metas = document.getElementsByTagName("meta"); | |
params = new Object(); | |
i = 0; | |
while (i < metas.length) { | |
meta = metas[i]; | |
switch (meta.name) { | |
case "csrf-token": | |
csrf_token = meta.content; | |
break; | |
case "csrf-param": | |
csrf_param = meta.content; | |
break; | |
default: | |
i++; | |
continue; | |
} | |
i++; | |
} | |
if (csrf_param !== undefined && csrf_token !== undefined) { | |
params[csrf_param] = csrf_token; | |
} | |
return params; | |
}; | |
config.addQueryString = function(url, params) { | |
var i, queryString; | |
queryString = []; | |
if (!params) { | |
return url; | |
} else { | |
for (i in params) { | |
queryString.push(i + "=" + encodeURIComponent(params[i])); | |
} | |
} | |
return url + (url.indexOf("?") !== -1 ? "&" : "?") + queryString.join("&"); | |
}; | |
CKEDITOR.on("dialogDefinition", function(ev) { | |
var content, dialogDefinition, dialogName, upload; | |
dialogName = ev.data.name; | |
dialogDefinition = ev.data.definition; | |
content = void 0; | |
upload = void 0; | |
if (CKEDITOR.tools.indexOf(["link", "image", "image2", "attachment", "flash"], dialogName) > -1) { | |
content = dialogDefinition.getContents("Upload") || dialogDefinition.getContents("upload"); | |
upload = (content == null ? null : content.get("upload")); | |
if (upload && upload.filebrowser && upload.filebrowser["params"] === undefined) { | |
upload.filebrowser["params"] = config.filebrowserParams(); | |
upload.action = config.addQueryString(upload.action, upload.filebrowser["params"]); | |
} | |
} | |
}); | |
config.title = false; | |
config.extraAllowedContent = 'section article header nav aside[lang,foo]'; | |
config.skin = 'moonocolor'; | |
config.extraPlugins = "stylesheetparser,autogrow"; | |
config.removePlugins = "forms"; | |
config.autoGrow_minHeight = 250; | |
config.autoGrow_maxHeight = 600; | |
config.autoGrow_onStartup = true; | |
config.autoGrow_bottomSpace = 30; | |
config.toolbar_Pure = [ | |
{ | |
name: 'document', | |
items: ['Source'] | |
}, { | |
name: 'styles', | |
items: ['Format'] | |
}, { | |
name: 'basicstyles', | |
items: ['Bold', 'Italic', 'Underline', 'Strike', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', '-', 'RemoveFormat'] | |
}, { | |
name: 'paragraph', | |
items: ['NumberedList', 'BulletedList', '-', 'Blockquote'] | |
}, { | |
name: 'table', | |
items: ['Table'] | |
}, { | |
name: 'hr', | |
items: ['HorizontalRule'] | |
}, { | |
name: 'colors', | |
items: ['TextColor', 'BGColor'] | |
}, { | |
name: 'urls', | |
items: ['Link', 'Unlink'] | |
}, { | |
name: 'insert', | |
items: ['Image', 'WPMore', 'Scayt'] | |
}, { | |
name: 'tools', | |
items: ['Maximize', 'ShowBlocks'] | |
} | |
]; | |
config.toolbar = "Pure"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment