-
-
Save kressly/956a03eea00a8c8a0e12f5de138cac07 to your computer and use it in GitHub Desktop.
Youtube, Vimeo and Dailymotion script
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 | |
if(preg_match('/vimeo/', $data['url'])){ | |
$url = '//player.vimeo.com/video/'.end(explode('/', $data['url'])); | |
echo "<iframe src='$url' width='560' height='315' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"; | |
echo "<img src='".unserialize(file_get_contents("http://vimeo.com/api/v2/video/".end(explode('/', $data['url'])).".php"))[0]['thumbnail_medium']."' />"; | |
}elseif(preg_match('/youtube/', $data['url'])){ | |
$url = '//www.youtube.com/embed/'.explode('=', $data['url'])[1]; | |
echo "<iframe width='560' height='315' src='$url' frameborder='0' allowfullscreen></iframe>"; | |
echo "<img src='http://i1.ytimg.com/vi/".end(explode("/", $url))."/hqdefault.jpg' />"; | |
}elseif(preg_match('/dailymotion/', $data['url'])){ | |
$url = 'http://www.dailymotion.com/embed/video/'.explode("_", end(explode('/', $data['url'])))[0]; | |
echo "<iframe frameborder='0' width='560' height='315' src='$url' allowfullscreen></iframe>"; | |
$img = "http://www.dailymotion.com/thumbnail/".explode('http://www.dailymotion.com/', $data['url'])[1]; | |
echo "<img src='$img' />"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment