This project is read-only.

Adding a YouTube embedded video in thread

Mar 7, 2013 at 2:05 PM
I wanted recently add the ability to post YouTube emebedded videos for administrators,

but I can’t really find the part of code (or the setting in tinyMCE) which purges the HTML of YouTube’s <object> or <iframe> tags.

Would you be so kind and point me the place where I should look?

Mar 7, 2013 at 3:45 PM
You could allow replacements, something like [youtube]identifier[/youtube]. Replacements can be defined at Site.config level.
Anyway, if this solution is no good for you and you want to change the behaviour, check the method SafeHtml on NearForums.Web.Extensions.StringExtensions.

Kind Regards,
Mar 8, 2013 at 3:18 PM
I'm not precisely sure what do you mean by defining replacements.
Do you mean, that I should add YouTube video to the tineMCE between for example these tags: [youtube]video_id[/youtube] - ([youtube]tRMDy-2uKus[/youtube])
and then using replacement rule in Site.config change the above to the result piece of code like this:
<iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>?

I hope I understood you well.
Mar 8, 2013 at 7:16 PM
Yes, for example you could add on the Site.config something like:
<add pattern="\[youtube\]([\w\-]+)\[/youtube\]"
             replacement="&lt;iframe width="560" height="315" src="$1" frameborder="0" allowfullscreengt;&lt;/iframe&gt;" />
Disclaimer: Consider this snippet as a sample, I did not tested it!!!! :)

Mar 11, 2013 at 12:56 PM
It works like a charm.
Thank you very much :)