News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Auto embed HTML5 youtube with Flash and plain link fallback

Started by Aaron10, August 19, 2014, 10:40:59 AM

Previous topic - Next topic

Aaron10

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

Suki


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.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Aaron10

That requires enabling HTML BBC though, doesn't it? And people would need to use the iframe code rather than just posting a link.

Suki

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.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Aaron10

There's no mod for HTML5 youtube, the closest is Simple Audio Video Embedder which uses the <embed> tags, which is invalid HTML5 anyway

Suki

<embed> is actually a HTML5 tag so it couldn't be invalid.

Mine does use an iframe for embedding.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Aaron10

Oh I didn't know yours had the auto embed thing, thought it was just BBC, will give it a try then thanks.

Advertisement: