croceldon
croceldon

Reputation: 4595

How to prevent CKEditor from adding inline height, width styles to img tags?

I have the following in my configuration:

config.allowedContent = true;
config.disallowedContent = 'img {width,height}';

Still, when adding an image, saving the form, and looking at the resulting HTML, I see:

<img src="/uploads/ckeditor/pictures/759/image.jpg" style="width: 227px; height: 300px;">

Based on all the docs I've read, and answers I've seen on SO, those two config lines should take care of it, but they don't.

Upvotes: 1

Views: 1475

Answers (1)

Anna Tomanek
Anna Tomanek

Reputation: 2239

As the Disallowed Content documentation explains:

It is not possible to disallow content when the Advanced Content Filter is disabled by setting CKEDITOR.config.allowedContent to true.

If you want to proceed in this way ("allow everything, except inline width and height styles on images") check the How to Allow Everything Except... section.

However, a much better solution would be to just extend the automatic mode and disallow what you need as described in the Automatic mode but disallow certain tags/properties scenario.

Upvotes: 5

Related Questions