insert image ckeditor code example

Example 1: ckeditor with image upload

Inside the config.js of ckeditor add the following code 

CKEDITOR.editorConfig = function( config ) {
	..............
    ..............
    ..............
    
    config.filebrowserUploadMethod = 'form',
	config.filebrowserUploadUrl = '/api/v1/ckeditor/upload-image',
	config.image_previewText = CKEDITOR.tools.repeat(' ', 1);
    
    ..............
    ..............
    ..............
};

For more details :

https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-filebrowserUploadMethod

Example 2: how add class to ckeditor image

editor.on('insertElement', function(event) {
	var element = event.data;
	if (element.getName() == 'img') {
		element.addClass('contentimage');
	}
});

Tags:

Misc Example