Skip to content

Instantly share code, notes, and snippets.

@bepatrickdavid
Last active August 29, 2015 14:23
Show Gist options
  • Save bepatrickdavid/f2b4e373c31e2147f452 to your computer and use it in GitHub Desktop.
Save bepatrickdavid/f2b4e373c31e2147f452 to your computer and use it in GitHub Desktop.
WP: shortcode video HTML5
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&amp;autoplay=true&amp;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