Search code examples
ckeditorckeditor4.x

Hide but not remove Image button CKEditor


In CKEditor, I added my custom image button, which directly trigger a file input. However, images can only be rendered when the Image plugin is in use.

I don't want to have 2 image buttons on the toolbar, is there a way to hide the Image button, but still use it (like display: none but in a more structural way?)

Thanks in advance.


Solution

  • Since 'CKEditor 4.1' you have something which is called Advanced content filtering. This allows you set enable or disable certain tags.

    The easiest way to allow the images to be displayed is to add

    config.allowedContent = true;
    

    in your config.js file. But this will allow everything.

    To just add the enablement of the 'img' tag you can add it in the 'extraAllowedContent' element when you create the CKEditor

        var myEditor = CKEDITOR.replace(editorId, {
        extraAllowedContent : 'img(*){*}[*]'
        });