html5 YouTube embeds for WordPress oembed

Oembed is brilliant! If you’ve got an URL, a simple call to a page and you can get back a lovely bit of JSON telling you how to embed the content. If you haven’t read up on it here is the standards page  http://oembed.com/

WordPress by default requests the standard swf embed from youtube. If you want to update your template to use the iFrame html5 player, YouTube have an iframe=1 parameter you can add when sending the oembed request. You can override the existing oembed provider inside your wordpress template using the following.

wp_oembed_add_provider( '#http://(www\.)?youtube.com/watch.*#i',

'http://www.youtube.com/oembed?iframe=1', true );

I’ve added it to my functions.php in my template, you could edit the class-oembed.php file directly if you wanted but any future updates will overwrite it.

Now all your clips will come through in html5 for all to see!

This entry was posted in Uncategorized. Bookmark the permalink.

Comments are closed.