Reputation: 1624
I am using ckeditor. I checked which elements were disallowed by default by running:
ckEditor.on( 'instanceReady', function() {
console.log(JSON.stringify(ckEditor.filter.allowedContent, null, '\t'));
});
This shows that the img
element is allowed (despite the fact that the img button does not appear in my toolbar).
Since I don't wish for users to be able to submit code with the img
element, I wanted to disallow this altogether. I tried disallowing it in the config.js
file with:
config.disallowedContent = 'img';
and also tried when initializing the editor:
CKEDITOR.replace("comment", {
disallowedContent: 'img'
});
When I display the allowed content with the ckEditor.filter.allowedContent
command, the img
element is still shown as allowed.
What am I doing wrong? I figure it's still necessary to disallow img
for cases where someone pastes code in the editor...
(I'm also validating server side but would ideally like for server side and client side to match, ie: for both to disallow img
).
Thanks
Upvotes: 1
Views: 901
Reputation: 2445
In order to disallow images please use below code:
CKEDITOR.replace( 'editor1', {
disallowedContent: 'img'
});
Please note that CKEDITOR.instances.editor1.filter.disallowedContent
and
CKEDITOR.instances.editor1.filter.allowedContent
are two separate lists and adding element to one doesn't remove it from other. You define (or editor does that by default) list of allowed elements in allowedContent list and list of disallowed elements in disallowedContent list. The later has higher priority than the former one - https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_disallowed_content. This is why images won’t be allowed in the editor.
Upvotes: 1