Friday, April 27, 2012

[YouTube-API] How to get the 120px/90px thumbnail using Oembed.

Im using Oembed to get the thumbnail of a video from a submitted url but it returns the 480px/360px size instead of the 120px/90px default version which is the size I use to display them. It's causing alot of unnecessary cropping so I'd like to know how I can the 120px/90px version using the code below.

   <code>
      <?php 
     require_once(ABSPATH.'wp-includes/class-oembed.php');       $oembed= new WP_oEmbed;       $name = get_post_meta($post->ID,'video_code',true);       $url = $name;      //As noted in the comments below, you can auto-detect the video provider with the following       $provider = $oembed->discover($name);      //$provider = 'http://www.youtube.com/oembed';       $video = $oembed->fetch($provider, $url, array('width' => 300, 'height' => 175));       $thumb = $video->thumbnail_url; if ($thumb) { ?>         <img src="<?php echo $thumb; ?>" width="120px" height="90px" />     <?php } ?>
   </code>

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/-EocFIWypDcJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment