Last active
August 29, 2015 14:23
-
-
Save bepatrickdavid/f2b4e373c31e2147f452 to your computer and use it in GitHub Desktop.
WP: shortcode video HTML5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function video_dp_shortcode( $atts ) { | |
extract( shortcode_atts( | |
array( | |
'poster' => NULL, | |
'mp4' => NULL, | |
'ogg' => NULL, | |
'webm' => NULL, | |
), $atts ) | |
); | |
$html = '<video width="100%" autobuffer preload="auto" controls poster="'.$atts['poster'].'">'; | |
$html .= '<source src="'.$atts['mp4'].'" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2">'; | |
$html .= '<source src="'.$atts['ogg'].'" type="video/ogg; codecs="theora, vorbis">'; | |
$html .= '<source src="'.$atts['webm'].'" type="video/webm">'; | |
$html .= '<object width="1080" height="720" type="application/x-shockwave-flash" data="js/flashmediaelement.swf">'; | |
$html .= '<param name="movie" value="js/flashmediaelement.swf" />'; | |
$html .= '<param name="flashvars" value="controls=true&autoplay=true&file='.$atts['mp4'].'" />'; | |
$html .= '</object>'; | |
$html .= '<img src="'.$atts['poster'].'" alt="video">'; | |
$html .= '</video>'; | |
return $html; | |
} | |
add_shortcode( 'video_dp', 'video_dp_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment