Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Embed an iframe into a page

Go to End

9 Posts   8861 Views


Community Member, 1 Post

11 March 2009 at 10:55pm

Hi o/ I have a problem embeding iframes into a page :( I'm using SS 2.3.0 and I can't embed iframe like google maps.I searched on the forum but it didn't help. I tried this method:To enable it, add iframe[src|width|height] to extended_valid_elements in /cms/javascript/tinymce.template.js. After adding it would look like this extended_valid_elements : "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],iframe[src|width|height]" - but when I opened that file there wasn't that string. Help


Community Member, 10 Posts

18 March 2009 at 3:24am

In SS 2.3.0 the code you want to change is commented out in /cms/javascript/tinymce.template.js

look in jsparty\tiny_mce2\tiny_mce_src.js

search for 'valid_elements :' should around line 6760

add iframe[src|width|height] here and that should do the trick for you


Community Member, 8 Posts

19 March 2009 at 2:49am


I want to try to do the same , embed an inframe, but hacking jsparty/tiny_mce2/tiny_mce_src.js by adding iframe[src|width|height] in the valid elements list doesn't work for me.

I am running ss 2.3.0.

Do you have to do anything after add ?



Community Member, 10 Posts

20 March 2009 at 10:37am

Edited: 20/03/2009 10:42am


Below is the code I added, but adding iframe[src|width|height] also worked for me.

... img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],iframe [align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight| marginwidth|name|scrolling<auto?no?yes|src|style|title|width],-sub, ...

The contents of the iframe don’t load in the content editor (though you can set a border in editor.css to see where it is located), but do in the live site. The above just ensures the html is not striped out completely.

I am using 2.3.0-rc2, mistakenly said 2.3.0 in earlier post


Community Member, 904 Posts

4 April 2009 at 6:06am

If you don't need the iframe to be inside your text-content, but rather at the beginning or bottom of the page, you could simply create a special Page-Type for this scenario.

class EmbedPage extends Page
	public static $db = array(
		'EmbedCode' => 'HTMLText'
	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Content.Main', new TextareaField('EmbedCode', 'Embed Code'));
		return $fields;

class EmbedPage_Controller extends Page_Controller {}

In the CMS you'll get a TextArea where you can paste your iframe code.
In the template you just add $EmbedCode below or above your content. For example:

<div class="typography">


74 Posts

12 July 2009 at 2:04pm

Thanks! This helped me out a lot!


Community Member, 8 Posts

20 July 2009 at 12:35am

Just updated SS to 2.3.2 and you can embed a iframe through the edit html source button.

Thanks SS team and others.



Community Member, 3 Posts

27 November 2014 at 12:50pm

Is there any way to stop the iframe being wrapped by a p tag?

Go to Top