Shortcode for HTML5 Video Tag in WordPress
by Bandicoot Marketing on | Posted in Tutorials | 11 comments
HTML5 has made it a lot easier to include certain elements. Especially videos, since you no longer have to embed them with all those parameters. Here’s a short code snippet that will add an HTML5 video shortcode to WordPress. Just include this code in your functions.php file and you are ready to go:
function html5_video($atts, $content = null) { extract(shortcode_atts(array( "src" => '', "width" => '', "height" => '' ), $atts)); return '<video src="'.$src.'" width="'.$width.'" height="'.$height.'" controls autobuffer>'; } add_shortcode('video5', 'html5_video');
Now you can use the following shortcode in your post:
[video5 src="http://your-site/videos/your-video.mp4" width="720" height="480"]
You can read more on which browsers support which formats at http://en.wikipedia.org/wiki/HTML5_video.
11 comments for “Shortcode for HTML5 Video Tag in WordPress”