Skip to content

Instantly share code, notes, and snippets.

@jimmylatreille
Created January 28, 2014 20:54
Show Gist options
  • Select an option

  • Save jimmylatreille/8676216 to your computer and use it in GitHub Desktop.

Select an option

Save jimmylatreille/8676216 to your computer and use it in GitHub Desktop.
Youtube, Vimeo and Dailymotion script
<?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' />";
}
?>
@kressly

kressly commented Mar 29, 2018

Copy link
Copy Markdown

Wow thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment