Adding Flash animation in SharePoint Blog and other lists pt. 1

February 26th, 2008 | Categories: SharePoint | Tags:

SharePoint’s rich text field is much better than in version 2.0. It even enables to edit the HTML source. But one thing I don’t understand is why it filters out the HTML code so much that we can’t even embed the Flash animations or videos into the content. This is a major drawback for SharePoint Blog.

Fortunately I’ve come up with a nearest thing to a remedy. It’s using Deconcept SWF object. It will replace an "alternative" content in a layer with a flash animation (this is also a good way to bypass the "Click to activete this control…" issue in IE). 

Let’s say we have a blog and a video to embed for example – this one from YouTube. A simple way of doing it – if you have only one video in the page is:

1. Create a document library and upload the swfobject.js (downloaded from author’s website) to it (or just upload it to the root of your website with SharePoint Designer).

 

2. Add a blog post and in the body edit the HTML code and insert the following code:

<div id="flashcontent">Please check this post on my website to view the video</div>

3. In the blog homepage and in the post details page (post.aspx), add a Content editor webpart and edit the source. Enter the following code:

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
    var so = new SWFObject("http://www.youtube.com/v/Z2yNzw00mpA&rel=1", "mymovie", "425", "355", "8", "#FFFFFF");
    so.write("flashcontent");
</script>

For comparison I’m pasting also the YouTube’s embed code and I’m color coding it to match the script:

<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Z2yNzw00mpA&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/Z2yNzw00mpA&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>

For more details on the script and how to add flashvars. Just be sure to have the right path to swfobject.js and to have the right ID of the div and in the script (in the case above: "flashcontent".

This is the result:

 

Unfortunately in the RSS is still showing the alternate content.

 

This is the method of adding only one video per page. You’d need multiple div ids and you’t always need to add to the script below. Fortunately I’ve prepared a way of automating this. More about this… Stay tuned for my next post.

Technorati tags: SharePoint JavaScript Flash SharePoint Blog
  1. Anonymous
    April 7th, 2008 at 07:16
    Reply | Quote | #1

    Hi,
    I tried to add the video on the blog post but unfortunatly it is not working and the video is opening in the content viewer webpart but not on the blog post.
    Please help me to resolve this issue.

  2. Anonymous
    April 7th, 2008 at 08:07
    Reply | Quote | #2

    Hi BorG,
    A client recently asked me how to put video into a SharePoint blog post,by searching i found this article which is very helpful. But it is not working for me.
    1.I have created the documentlibrary and added the swfobject.js file
    2.Created the blog post and edited the html source for the body.
    3.Created the content editor webpart and the added the mentioned content

    But blogpost is showing only the body text but not the video.

    Please help me where iam doing the mistake and if possible kindly demonstrate using screenshots.

    Thanks in Advance

  3. Boris Gomiunik
    April 7th, 2008 at 08:10
    Reply | Quote | #3

    You can’t just copy-paste the embed code. The content editor will show properly, but when saving to SharePoint list, the embed code will get filtered out. The only way is as I described in this post. Make sure you:

    1. have the javascript refferenced
    2. have the code in all the pages displaying the post with video
    3. have the correct layer information in the post.

  4. fendi164
    April 26th, 2008 at 07:49
    Reply | Quote | #4

    Hi, the post is great but i have a bit of a problem. My blog homepage does not have a Content editor webpart to be added. How can i add the webpart editor to my list of webparts to add when i design the page ?
    Thanks.

    Affendi

  5. Boris Gomiunik
    April 27th, 2008 at 13:49
    Reply | Quote | #5

    If your Blog SharePoint website doesn’t have Content Editor Webpart in a list, this is probably, because your top-level website was deployed like a blog. That’s nothing wrong with it, Just your webpart library didn’t get populated with standard webparts. If you have the option to create a new top-level website, create a blank site or a team site. Then open the webpart galery (_catalogs/wp), download all the webparts and upload them to the WP galery of your Blog site.