Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: Aaron10 on August 19, 2014, 10:40:59 AM

Title: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: Aaron10 on August 19, 2014, 10:40:59 AM
I know there's mods that do this already, but what I'm after is when someone posts a URL (https, http, youtu.be etc) it's automatically embedded but via HTML5, and if the browser doesn't support it, flash, and if the browser doesn't support that, just display the regular link.

My forums are HTML5 valid so there shouldn't be any problems.

<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/yyTPiR53aII?rel=0" style="border: none;" allowfullscreen></iframe>

Apparently this code automatically has a fallback to flash/object for browsers not supporting HTML5. And if the browser supports neither, just display a link:

https://www.youtube.com/watch?v=yyTPiR53aII
Title: Re: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: All Colours Sam on August 19, 2014, 11:06:03 AM

The iframe tag is still valid on HTML5 so if you use an iframe, your site will still be HTML5 compliant.

Youtube indeed will use the <embed> tag on browsers that support it, so you really don't need to do anything other than keep using an iframe.
Title: Re: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: Aaron10 on August 19, 2014, 12:01:10 PM
That requires enabling HTML BBC though, doesn't it? And people would need to use the iframe code rather than just posting a link.
Title: Re: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: All Colours Sam on August 19, 2014, 12:04:43 PM
Nope, if you use a mod that specifically uses iframes, you don't have to use any HTML bbc tag, the mod will automatically take care of that for you.
Title: Re: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: Aaron10 on August 19, 2014, 02:15:25 PM
There's no mod for HTML5 youtube, the closest is Simple Audio Video Embedder which uses the <embed> tags, which is invalid HTML5 anyway
Title: Re: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: All Colours Sam on August 19, 2014, 02:45:54 PM
<embed> is actually a HTML5 tag so it couldn't be invalid.

Mine (http://custom.simplemachines.org/mods/index.php?mod=3268) does use an iframe for embedding.
Title: Re: Auto embed HTML5 youtube with Flash and plain link fallback
Post by: Aaron10 on August 19, 2014, 11:36:44 PM
Oh I didn't know yours had the auto embed thing, thought it was just BBC, will give it a try then thanks.