Search code examples
ckeditoramp-html

Stop ckeditor from adding non amp codes


Is there a way to make ckeditor compatible with AMP? ckeditor keeps adding inline styles to images tags which spoils AMP.


Solution

  • If you can't use any inline styles for content created in CKEditor, please try using the following (Advanced Content Filter (ACF) can't be disabled for this to work):

    var editor = CKEDITOR.replace( 'editor1', {
            allowedContent : {
                $1: {
                    // This will set the default set of elements.
                    elements: CKEDITOR.dtd,
                    attributes: true,
                    styles: false,
                    classes: true
                }
            }
    });
    

    If you only want to disallow styles for images, please use:

    var editor = CKEDITOR.replace( 'editor1', {             
                     disallowedContent : 'img{width,height}'
    });
    

    To learn more about ACF, please see: