Embed YouTube video in Forum

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/19/2013 6:31:31 AM
Gravatar
Total Posts 8

Embed YouTube video in Forum

Hi, a little useful  script

add this script block at the bottom of  \Forums\Controls\PostList.ascx

and all links (like <a href='http://www.youtube.com/watch/....somevideolink'>) posted from any users in forum threads will transform into youtube embedded objects bypassing NeatHtml

<script>

$(document).ready(function(){

var vidWidth = 425;

var vidHeight = 344;

$('div.postbody a[href*="youtube.com/watch"]').each(function(){

  var that = $(this);

  var txt = $(this).attr('href');

  var e1 = '<br /><obj'+'ect width="' + vidWidth + '" height="' + vidHeight + '"><param name="movie" value="http://www.youtube.com/v/';

  var e2 = '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" ' +

   'value="always"></param><em'+'bed src="http://www.youtube.com/v/';

  var e3 = '&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + vidWidth +

   '" ' + 'height="' + vidHeight + '"></embed></object> ';

  var vid = txt.match('[\\?&]v=([^&#]*)');

  if (vid.length) {

        that.append( e1 + vid[1] + e2 + vid[1] + e3 ) ;

  }

})

});

</script>

6/19/2013 7:18:52 AM
Gravatar
Total Posts 18439

Re: Embed YouTube video in Forum

Hi,

I recommend that people do not modify any mojoPortal code. As soon as you fork the code you can no longer upgrade without losing your changes and I have no interest in providing support for forked versions.

You can bypass NeatHtml in the forum by marking the user as trusted in ManageUsers.aspx.

The forum editor toolbar could also be modified by configuration to include the oembed plugin which supports youtube and others.

However I would only not mark strangers as trusted.

Please don't post advice in these forums advising people to modify mojoPortal code.

If you do  want to make a change like that then make a separate skin for the forum page and put your script in layout.master rather than modify PostList.ascx

Thanks,

Joe

6/19/2013 7:49:58 AM
Gravatar
Total Posts 8

Re: Embed YouTube video in Forum

ок.

You must sign in to post in the forums. This thread is closed to new posts.