-
-
Save markthepixel/7829081 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// YouTube ShortCode [youtube src="" title="" duration="" thumbnail="" description=""] | |
function youtube_shortcode( $atts ) { | |
extract(shortcode_atts(array( | |
'src' => '', | |
'title' => '', | |
'duration' => '', | |
'thumbnail' => '', | |
'description' => '' | |
), $atts)); | |
$video_tag = '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">'; | |
if ($title != ''){ | |
$video_tag .= '<h2><span itemprop="name">' . $title . '</span></h2>'; | |
} | |
if ($duration != ''){ | |
$video_tag .= '<meta itemprop="duration" content="' . $duration . '" />'; | |
} | |
if ($thumbnail != ''){ | |
$video_tag .= '<meta itemprop="thumbnailUrl" content="' . $thumbnail . '" />'; | |
} | |
$video_tag .= '<meta itemprop="embedURL" content="http://youtu.be/' . $src . '" />'; | |
$video_tag .= '<div class="video-container"><iframe src="//www.youtube.com/embed/' .$src. '?hd=1" frameborder="0" allowfullscreen></iframe></div>'; | |
if ($description != ''){ | |
$video_tag .= '<span itemprop="description">' . $description . '</span>'; | |
} | |
$video_tag .= '</div><br />'; | |
return $video_tag; | |
} | |
add_shortcode('youtube', 'youtube_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment