How to add class or attribute automatically to img tags in CKEditor?

前端 未结 5 1840
眼角桃花
眼角桃花 2020-12-31 21:20

I\'m using CKEditor version 3.6

I want to automatically add class=\"newsleft\" to any image tag added through the WYSIWYG.

I\'ve seen a few post

5条回答
  •  灰色年华
    2020-12-31 22:03

    Because of this topic is being found in Google very high, I might help people by answering the question: how to add a default class when inserting an image in CKeditor. This answer is for CKeditor 4.5.1. as this is the latest version right now.

    1. Look up image.js in /ckeditor/plugins/image/dialogs/image.js
    2. Search for d.lang.common.cssClass
    3. You will find: d.lang.common.cssClass,"default":""
    4. Edit it with your class name(s) such as: d.lang.common.cssClass,"default":"img-responsive"

    I've tried this and it works!

提交回复
热议问题