Sean Oh
Sean Oh

Reputation: 31

ckeditor how to put <br> after image upload

I have searched for this answer and I thought I've found it. Someone suggested this one.

editor.on('instanceReady', function() {
    editor.widgets.registered.uploadimage.onUploaded = function(upload) {
        this.replaceWith('<img src="' + upload.url + '"><br>br>');
    }
});

But my question is where should I put this function?

should it go to config.js like

CKEDITOR.editorConfig = function(config) {
    //...
};
editor.on('instanceReady', function() {
    editor.widgets.registered.uploadimage.onUploaded = function(upload) {
        this.replaceWith('<img src="' + upload.url + '"><br>br>');
    }
});
// ----------------------------------

Upvotes: 0

Views: 183

Answers (1)

Sean Oh
Sean Oh

Reputation: 31

I found the solution.

I had to do this in the html.

<script>
editor = CKEDITOR.replace('contents');
editor.on('instanceReady', function() {
    editor.widgets.registered.uploadimage.onUploaded = function(upload) {
        this.replaceWith('<img src="' + upload.url + '"><br><br>');
    }
});
</script>

Upvotes: 1

Related Questions