I am using the CKeditor module only as an administrator, so I don't need any security protection.

When I add Google Adsense code into a block, CKeditor stripes away the <ins> tag. I am aware of this solution though I rather want CKeditor to not stripe away anything. In other words: I don't want to whitelist any tags, I just want to be sure that nothing gets deleted. Is there a solution for this?

Another way might be: Can I configure the Switch to plain text editor toggle to START with a plain text editor as default, allowing me to Switch to rich text editor?

UPDATE: Some additional info: I'm using the latest version of CKeditor, loaded from: //cdn.ckeditor.com/4.4.3/full-all

The profile in use is "Full HTML". In its settings at ADVANCED CONTENT FILTER "disabled" is checked. In ADVANCED OPTIONS, Custom JavaScript configuration, I have set:

config.fillEmptyBlocks = false;
config.autoParagraph = false;
config.allowedContent = true;

To reproduce the problem, just toggle to plain text, paste the following HTML, toggle to rich text and to plain text again. Only "foo bar" will remain.

foo <ins class="adsbygoogle" style="display:inline-block" ></ins> bar
  • Are you using drupal.org/project/adsense or is this entirely custom?
    – webkenny
    Commented Dec 22, 2014 at 18:53
  • No, I'm not using the Adsense module, just normal blocks (with CKEditor though). Commented Dec 22, 2014 at 21:41
  • I asked because I suspect your life could be easier using the module. It has built in support for what it sounds like you're attempting to do and won't bring the headache of wrangling with CKEditor.
    – webkenny
    Commented Dec 22, 2014 at 22:00
  • Well, I don't like the fact that it changes the Adsense code, thus violating Google's TOS. And I might later also use other Ad code. But still, thanks for your suggestions! Commented Dec 23, 2014 at 1:49
  • 1
    Note that DeepFriedBits' comment on the answer to the question you linked to above mentions that adding anything inside the <ins> tag solves the problem. If that's true, you could use <ins class="adsbygoogle" style="display:inline-block" >&nbsp;</ins> and completely solve the problem. Alternatively, if you don't need to rearrange the ad positions, I'd consider inserting the code directly in the theme template files.
    – bhotel
    Commented Dec 23, 2014 at 21:35

3 Answers 3


Even 'Full HTML' does some html tampering - you could try creating a new text format for Admins only without any restriction at all - this is what I usually do for adsense and it has always worked great without the need for another module.

  • You mean creating a new Drupal Text format at admin/config/content/formats? It's unlikely that this helps because without CKeditor, the given Full HTML format works as desired (no deletion happens). But I gave it a try: I created newformat, applied CKEditor's profile "Full" also to newformat. Result is the same: The <ins> tag disappears. Commented Dec 23, 2014 at 13:45
  • why do you need ckeditor as part of this one time, code copy and paste? It sounds like you're overcomplicating this process
    – Geoff
    Commented Dec 23, 2014 at 15:24
  • I need CKeditor for Node creation and for other blocks. Commented Dec 23, 2014 at 19:50
  • I understand the need for CKEditor in general, but you don't need it to copy and paste adsense code into a block, meaning you can use a text format in that specific block that does not require ckeditor in order to ensure the code is formatted correctly.
    – Geoff
    Commented Dec 23, 2014 at 22:49
  • Oh, now I get: I define something like "Full HTML without CKeditor" being a clone of "Full HTML", just without CKeditor. Yeah, that's a good idea. Commented Dec 23, 2014 at 23:23

Depending on your CKEditor version, it may be the "Advanced Content Filter" at work there.

ACF is a highly configurable CKEditor core feature available since CKEditor 4.1. It limits and adapts input data (HTML code added in source mode or by the editor.setData method, pasted HTML code, etc.) so it matches the editor configuration in the best possible way. It may also deactivate features which generate HTML code that is not allowed by the configuration.

In particular

If you want to disable Advanced Content Filter, set CKEDITOR.config.allowedContent to true. All available editor features will be activated and input data will not be filtered. Note that you cannot use CKEDITOR.config.disallowedContent when ACF is disabled.

Documentation on configuration of ACF can be found here: http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter

  • I just added some info to my question. Yes, I've already set allowedContent to true – but it doesn't help. Commented Dec 23, 2014 at 1:50

Partial solution/workaround: I found the option to start the plain/rich text toggle with the plain text editor. That way, I can edit the Google Adsense blocks without them being messed up, and on other blocks I just switch on the CKeditor if I need it.

Where the setting is: config/content/ckeditor -> Profiles, Edit -> EDITOR APPEARANCE -> Default editor state: Disabled

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.