Last active
November 9, 2020 12:12
-
-
Save prolificjones82/e4d22fddd6fccb29c132 to your computer and use it in GitHub Desktop.
YouTube Video Display
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
<?php | |
// get youtube video id | |
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $attrs['videoid'], $matches); | |
$id = $matches[0]; | |
// get video title | |
$content = file_get_contents('http://youtube.com/get_video_info?video_id='.$id); | |
parse_str($content, $ytarr); | |
// variables | |
$ytAnchor = '//www.youtube.com/embed/'.$id.'?autoplay=1&showinfo=0&modestbranding=1'; | |
$ytIframe = '//www.youtube.com/embed/'.$id.'?showinfo=0&modestbranding=1'; | |
$ytThumb = '//img.youtube.com/vi/'.$id.'/maxresdefault.jpg'; | |
$ytTitle = $ytarr['title']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment