james
james

Reputation: 717

CKEditor- style attribute gets stripped out for certain text formats

I've set up a text format called contributor and have allowed tags in the allowed tags html filtering.

I've configured CK by disabling ACF. I've also put in "config.allowedContent = true;" into the Custom JavaScript Configuration textarea, in the Adavanced Options section. All CK profiles I've done this for. This usually works for me, btw.

I have the styles dropdown in my toolbar for the CK profile that uses the contributor text format. I've copied the configuration.styles.js file into my theme and have created a style to float my images to either side- left or right. Coding is like this:

...
{
    name: 'Image on Left',
    element: 'span',
    attributes: {
        'style': 'float:left;margin-right:1em;'
    }
},
{
    name: 'Image on Right',
    element: 'span',
    attributes: {
        'style': 'float:right;margin-left:1em;'
    }
},
...

I see the styles for floating in my dropdown and when I apply them they seem to work (in the CKEditor); I can view source while still using the editor and see my image I had selected is wrapped in a span with a style attribute. But when I save my node, the span tag is there but the style attribute is stripped out. I've tried altering my JS to apply the float style to the image tag, and I get the same thing. I can see the style="float:left;margin-right:1em" in the img tag in the html source. Seems attributes get stripped. Am I missing something?

Upvotes: 1

Views: 413

Answers (2)

CertifiedGeek
CertifiedGeek

Reputation: 137

Double check your filters on the text formats: admin -> config -> content -> formats and to be sure, you could create a text format that has no filters applied and try setting that in your profile.

Additionally, sometimes when I've added custom configuration options, I've had to delete all the profiles, flush cache (both Drupal and browser) then recreate profiles and it will work.

Upvotes: 0

AlfonsoML
AlfonsoML

Reputation: 12690

If the code is correct in the source view, then the problem is that your server side code is stripping out those styles.

Check your configuration of Drupal.

Upvotes: 0

Related Questions