Friday, November 2, 2012

Embed video in SharePoint 2010 blog posts - the easy way

2nd Edit: Added a link to the script file as copying from this page introduces illegal characters
NEW source file supporting multiple browsers!

Edit: Added some more explanation around the Content Editor and the script.

Embedding videos to the Body of a blog post in SharePoint has always required some tricks and coding.
If you Google the internet you may come accross posts like Embedding Flash Video in SharePoint Blogs by Kirk Evans and the ERTE project on Codeplex by Boris Gomiunik.

I've taken some inspiration in both these approaches, but wanted a solution that didn't include adding code to masterpages or installing solutions. Simplicity should be the key word. So my solution makes it possible to paste the embed code directly into the body text and hit Publish.And get the video working. To do this you simply add a Content Editor web part (CEWP) to the bottom of your page.

To edit the HTLM source of the CEWP (click Edit page and) click in the Editor part of the web part
Now in the ribbon locate the HTML icon, click the dropdown arrow and click on Edit HTML Source
Once in the HTML Source editor add the below script and click OK:

You can find the script file here: EmbedVideo.txt

Once the HTML Source editor is closed, click Page, Stop Editing.

After you done this the script should NOT show up on the page, if it does, then is has not been successfully entered into the HTML Source, examine it for any illegal characters that might occur from copying it from this page.

Once the script is successfully entered into the HTML of the CEWP you should be ready to move on!

Now you can paste the embed code directly into body text or you can even include embedded videos to items on a custom list or wherever you want...



And the result:



Or even in a custom list or as here a Link list using a Enhanced Rich Text field:

So, happy embedding :)