This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

Get youtube video screenshot using simple php and javascript

Simple script to get the screenshot of a particular URL from youtube,

<script type="text/javascript">
function getScreen( url, size ) {
if(url === null){
return ""; } size = (size === null) ? "big" : size; var vid; var results;

 results = url.match("[\\?&]v=([^&#]*)");

 vid = ( results === null ) ? url : results[1];

 if(size == "small"){
 return "http://img.youtube.com/vi/"+vid+"/2.jpg"; }
 else {
 return "http://img.youtube.com/vi/"+vid+"/0.jpg"; }
 }

</script>

<?php  $url = "http://www.youtube.com/watch?v=hQVTIJBZook";
echo $url;
 ?>

<script type="text/javascript">

var imgUrlbig = getScreen("<?php echo $url ?>");
var imgUrlsmall = getScreen("<?php echo $url ?>", 'small');

document.write('<img src="' + imgUrlbig + '" />');
document.write('<img src="' + imgUrlsmall + '" />');

</script>
VN:F [1.5.7_846]
Rating: 10.0/10 (3 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • Xerpi

Related posts:

  1. Embedding youtube video in wordpress
  2. Simple Ajax with PHP click tracker

Leave a Reply

Spam Protected