Created
April 13, 2012 16:37
-
-
Save DfKimera/2378224 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: Retorna o link do Youtube embedado | |
| * @param string $url | |
| * @return string 'http://www.youtube.com/embed/'.$codigo; | |
| */ | |
| public static function youTubeVideo($url){ | |
| preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches); | |
| return 'http://www.youtube.com/embed/'.$matches[0]; | |
| } | |
| /** | |
| * Youtube: Retorna o thumb do Youtube | |
| * @param String $url | |
| * @return jpg | |
| */ | |
| public static function youTubeThumb($url){ | |
| preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches); | |
| return '//i1.ytimg.com/vi/'.$matches[0].'/hqdefault.jpg'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment