Search code examples
iframedrupalckeditor

ckeditor add <iframe> tag in editor


I am using ckeditor in a drupal 7 site. I want to put iframe tag inside the editor. Currently what happen when we put iframe in ckeditor.

<iframe src="http://www.lipsum.com/"></iframe>

It convert that iframe tag with a img tag with some special attribute and URL.

<img class="cke_iframe" data-cke-realelement="%3Ciframe%20src%3D%22http%3A%2F%2Fwww.lipsum.com%2F%22%20class%3D%22placeholder-tool%20helpTool-placeholder%22%20scrolling%3D%22no%22%20frameborder%3D%220%22%3E%3C%2Fiframe%3E" data-cke-real-node-type="1" alt="IFrame" title="IFrame" align="" src="http://testsite.com/sites/all/libraries/ckeditor/images/spacer.gif?t=C9A85WF" data-cke-real-element-type="iframe" data-cke-resizable="true">

Which I do not want. I want to make the ckeditor to print exact iframe tag there not the img tag like this.

<iframe src="http://www.lipsum.com/"></iframe>

So that If I want to perform a task in iframe so I can do that inside the editor.

Thank you in advance

Addition 2:

I need the iframe should work in editor itself. It should not convert iframe to img on node add or edit page also.

enter image description here

It should like this enter image description here

Not like this enter image description here enter image description here


Solution

  • Finally, I have to make one line change in ckeditor.js at line number 8194:

    return m.createFakeParserElement(p, 'cke_iframe', 'iframe', true);
    

    To

    return p;
    

    So it is not creating FakeParser for iframe. And when I put a iframe in edit mode so I see the iframe exactly not the image in place of that. It is a little hack I used for this functionality.

    Thank you Darko for help on this.