-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Integration with CKEditor
You must tell CKEditor where the file manager is.
CKEDITOR.replace( 'editor1', {
filebrowserBrowseUrl : 'path/to/editor/file', // eg. 'includes/elFinder/elfinder.html'
uiColor : '#9AB8F3'
});
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
config.filebrowserBrowseUrl = 'includes/elFinder/elfinder.html';
};
Edit elfinder.html
to get next code
<script type="text/javascript" charset="utf-8">
// Helper function to get parameters from the query string.
function getUrlParam(paramName) {
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i') ;
var match = window.location.search.match(reParam) ;
return (match && match.length > 1) ? match[1] : '' ;
}
$().ready(function() {
var funcNum = getUrlParam('CKEditorFuncNum');
var elf = $('#elfinder').elfinder({
url : 'php/connector.php',
getFileCallback : function(file) {
window.opener.CKEDITOR.tools.callFunction(funcNum, file.url);
window.close();
},
resizable: false
}).elfinder('instance');
});
</script>
Code Variations Type of data returned by elFinder is determined by it's options
window.opener.CKEDITOR.tools.callFunction(funcNum, file.url);
orwindow.opener.CKEDITOR.tools.callFunction(funcNum, file);
?
see https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commandsoptions
commandsOptions.getfile.onlyURL = false
is file.url
commandsOptions.getfile.onlyURL = true
is file
Alternate getFileCallback to help populate the new image2 insert dialog with dimensions
getFileCallback : function(file) {
window.opener.CKEDITOR.tools.callFunction( funcNum, EXPONENT.PATH_RELATIVE+file.url.replace(EXPONENT.URL_FULL, ''), function() {
var dialog = this.getDialog();
if ( dialog.getName() == 'image2' ) {
dialog.getContentElement( 'info', 'height' ).setValue( file.height ); //work-around
dialog.getContentElement( 'info', 'width' ).setValue( file.width ); //work-around
}
});
window.close();
},
http://elfinder.org/forum/#/20110728/integration-with-ckeditor-759177/
http://forrst.com/posts/Elfinder_2_0_beta_filemanager_for_the_web_Ex-PPS
http://elfinder.org/forum/#/20120619/ckeditor-3-1700374/