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

前端 未结 5 1854
眼角桃花
眼角桃花 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:11

    Here's another approach:

    CKEDITOR.on( 'instanceReady', function( evt ) {
      evt.editor.dataProcessor.htmlFilter.addRules( {
        elements: {
          img: function(el) {
            el.addClass('img-responsive');
          }
        }
      });
    });
    

提交回复
热议问题