Jump to content

iframes are being stripped from CKEditor field, even when explicitly allowed

Recommended Posts

Having some issue with getting an iframe to save on a CKeditor text field (2.5.3). Things I've done to explicity allow it:

- added "iframe[*]" to extraAllowedContent

- added "IFrame" to the CKEditor toolbar

- turned off CKEditor ACF

- switched the field's "Content Type" from "Markup/HTML" to "Unknown" 

When pasting in my iframe code (it's a Vimeo embed code), CKEditor shows the iframe placeholder, but after saving the page, it's stripped out. For testing, I tried adding a simpler iframe using CKEditor's iframe toolbar button, but that also gets stripped out after saving.

Anyone experiencing this, or have iframes working with their field?

Share this post

Link to post
Share on other sites

Thanks, Adrian. I'll be sure to try that out. I'm assuming it'll work with 2.5 even though it's not listed in supported versions.

Share this post

Link to post
Share on other sites

Yeah - it definitely works fine it 2.5 - hopefully Ryan will get around to updating the supported versions for it shortly.

Share this post

Link to post
Share on other sites

I'm having this problem as well, and I need iframes for other kinds of content (not just video), so the Video Embed module isn't a solution for me.  

  • Like 1

Share this post

Link to post
Share on other sites

It is definitely possible to allow iframes through CKEditor with the right settings, but I would suggest that the easiest option might be to set up a Hanna Code (http://modules.processwire.com/modules/process-hanna-code/) tag for inserting iframes. I have to head out, but hopefully someone else can give you an example if you can't figure it out.

Share this post

Link to post
Share on other sites

Here's how it worked for me in CKEditor (in case you persist on this route :-) - but I would go for Hanna Code as Adrian suggested. As usual, the "culprit" is our friend HTML Purifier (read from here up to and including Ryan's comment here about its pros and cons before deciding whether to implement #5 below!) 

  • For iframes, the Extra allowed content seems to have no effect - btw, the correct syntax here is for example, div(*) not div[*]
  • Add 'Iframe' (note the spelling) to your CKEditor Toolbar
  • Leave ACF on
  • No need to switch the field's "Content Type" from "Markup/HTML" to "Unknown" 
  • Turn HTML Purifier off (gasp! :undecided:  :-X  :-) )
  • Enjoy your embedded video :D
  • Like 12

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By prestoav
      Hi all and thanks for the great work on PW!

      One thing I find I have to do on any new site is add the Justify plugin to textarea fields as it is such a widely required feature for text headings in content.

      ANy chance this could be added to the core an automatically be installed on new textarea fields using CKEditor?

      Thank you!
    • By AndréPortuga
      Does anyone knows if there is a way of selecting a iframe inside a textfield(using ckEditor)? 
      I mean I have a Iframe with this code:
      <iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" scrolling="no" src="https://www.youtube.com/embed/PMaFJjZDrYM" width="100%"></iframe></p>
      but it's not getting responsive in iPhones.. So anyone know how can I select it via code for making it responsive?
      Thank you,
    • By dragan
      On one particular site, CKEditor behaves rather weird:
      When I copy and paste "normally", i.e. CTRL + V, there is an alert popping up "do you really want to leave this page?". If you cancel, the text is pasted into the field. If not, you get redirected to the frontend of the page you just edited, and the changes are lost.
      The "paste from Word" button doesn't work. CTRL + SHIFT + V works, but all formatting is lost (apart from paragraphs).
      I'm using inline editor mode, ACF + Purifier are activated. I know that if I disable those two, CTRL + V works, but I won't do that, since CKE then saves all the garbage code from MS-Office.
      Has anyone ever come across this issue? I tried with Chrome + FF. No JS errors.
    • By AndZyk
      I am currently building a intranet which will be hosted on the local network of a company. This intranet has many links to files on their fileserver with the protocol file://.
      So for example the links look like this file://domain.tld/filename.ext
      When I try to insert such a link into a URL field, I get the error, that only the protocol http:// is allowed. When I try to insert such a link into a CKEeditor link, it gets stripped out. Is it possible to insert such links into the FieldType URL and CKEditor.
      I know that I could use a FieldType Text or insert a RewriteRule in the .htaccess file, but I am looking for a more elegant solution. 😉
      Regards, Andreas
  • Create New...