YouTube Thumbnails w/o API
| Project: | Video CCK |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | aaron |
| Status: | active |
Jump to:
I read the Revver solution and its nice that they provide an easy resize option but the other services don't. This is a request to scale all the supported services to the same thumbsize for consistency and I think it would be scalable to any future needs. Right now the google thumbs are 4x larger than the youtube ones, but this can apply to any service.
Im not a coder so Ill try provide some examples, some code that grabs the thumb and resizes it for Youtube (mambo code but might be helpful)
// use youtube API, but in fact there's real hidden url at http://img.youtube.com/vi/VIDEO-ID/2.jpg
$apiurl = 'http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=MYSECRET&video_id=' . $matches[1];
$apiret = dh_get_contents($apiurl);
$begin = strpos($apiret, '<thumbnail_url>');
$end = strpos($apiret, '</thumbnail_url>', $begin);
if( $begin !== FALSE && $end !== FALSE ) $thumbnail_url = substr( $apiret, $begin+15, $end-$begin-15 );
$thumb = dh_get_contents($thumbnail_url);
$filename = str_replace($prefix, '', $filename);
file_put_contents($filename, $thumb);
// resize it
$new_img = resize($filename, $size['thumbnail'][0], $size['thumbnail'][1]);
file_put_contents($filename, $new_img);
echo $new_img;Drupals teaser_images.module , the code can be found near bottom under heimstein's post http://drupal.org/node/101748
Basically with if those could somehow be hacked into your module it could temp store the thumbnail and resize it automatically no matter what service is used, not positive but it most likely could use image cache http://drupal.org/node/101748
Another referance http://drupal.org/node/101748
Hope this helps cheers

#1
bumping this up -- that might be a better youtube solution, so people don't need an api key...