Blog » Adding YouTube and Vimeo buttons to embed content using the SilverStripe WYSIWYG editor.
Currently i'm developing a new web presence for Jodie Lee and I thought that it would be cool to make it easier for her to add YouTube and Vimeo videos to her site. I first had a look at the short codes but then decided that I would give modifying the WYSIWYG editor a crack. First of all, this requires changes to some of the core files, which is advised against if you ever need to upgrade the SilverStripe to a newer version.
First of all, I modified SilverStripe 2.4.5 All you need to do is just paste the code into your root directory. I've only included the files in the zip which I've modified
To keep with the style of the SilverStripe editor, I have used the ssbuttons style of adding content to the editor:

The editor with the included YouTube and Vimeo buttons.

The YouTube SilverStripe properties box

The Vimeo SilverStripe properties box.
What happens is these 2 property boxes will embed the old version of the YouTube embed code and the Vimeo embed code. The new version uses the iframe tag and this is not supported within the WYSIWYG editor.
Lets get to the details of what had to be modified!
We had to add some styles for the 2 new forms.
Added language definations for insertyoutube and insertvimeo.
Added language definations for insertyoutube and insertvimeo.
Added editor button references to the 2 new buttons.
A couple of images were used for the buttons called vimeo.png and youtube.png
Added the 2 new form placeholders. $YoutubeForm and $VimeoForm.
Change HtmlEditorConfig to reference the 2 new buttons.
Added the YoutubeForm and VimeoForm functions which create the forms.
Added javascript code to make the 2 forms functional.
Added language variables for the 2 forms.
I can see any problems which this shouldn't be included into the core. At the moment, the editor supports embedding a swf file and this is basically the same, except its sourced from another server.
Here is all of the code differences as from trac. For some reason, a lot of spaces have been added to the source code and count as differences.
CW says:
Sorted it. I have a en_GB site and not a en_US one. I made the lang changes to the en_GB file instead. Cheers
Posted by CW, 30 March 2012 (1 year ago)
CW says:
I'm having the same trouble as Katie. Firebug is telling me:
showForm is null
showForm.toggle(ed);
Line 55 of editor_plugin_src.js
Posted by CW, 30 March 2012 (1 year ago)
Katie says:
PS running 2.4.5 locally
Posted by Katie, 12 January 2012 (1 year ago)
Katie says:
Hi, I really like the look of this addition - I think it would be great if it was a standard inclusion.
I updated all the files and the Vimeo and YouTube icons are visible in the SS editor. However, when I click on the icons nothing happens.
Is there something that I have overlooked?
Posted by Katie, 12 January 2012 (1 year ago)
Markus says:
hi ,
thanks for the code helped me much to get deeper in the MCE editor. as mentioned earlier, i too changed the vimeo and youtube code to iframe instead of object. further more i added a html5 video pane. for those who are interested - the modified files in the link.
cheers
markus
Posted by Markus, 3rd September 2011 11:57 am (2 years ago)
gav says:
Hey Marina. I've just done a quick search and it appears that you can add an iframe to tinyMCE by modifying the extended_valid_elements. If this works, I\'ll write an editor button to insert a google map. I'll also update the youtube & vimeo buttons to you the iframe as this is the preferred way. I'll see if have some time today to give this a go.
Posted by gav, 29th May 2011 11:26 pm (2 years ago)
Marina says:
any chances you could do the same for googlemaps or an "add iFrame" tab in general? Greatly missing this feature in the tinyMCE and couldn´t really find help in the forums :-/
great job you did here btw :-)
Posted by Marina, 29 May 2011 (2 years ago)
RSS feed for comments on this page | RSS feed for all comments