Skip to content

Instantly share code, notes, and snippets.

@germanny
Created October 26, 2012 22:38
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save germanny/3961968 to your computer and use it in GitHub Desktop.
Save germanny/3961968 to your computer and use it in GitHub Desktop.
Get Vimeo 1280px poster image
// Vimeo serves up poster images in 100, 200 and 640. But there's also size they don't serve: 1280
// https://developer.vimeo.com/apis/simple
$vimeo_value = get_post_meta($post->ID, 'vimeo_value', TRUE);
$vimeo_video_id = substr($vimeo_value, strrpos($vimeo_value, '/')+1); // get just the id
$vimeo_xml_file = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vimeo_video_id.php")); // get the video data from the API
$vimeo_video_width = $vimeo_xml_file[0]['width'];
$vimeo_thumbnail_large = $vimeo_xml_file[0]['thumbnail_large']; // load up one of the image sizes
if($vimeo_video_width < 1280) {
$vimeo_thumbnail = $vimeo_thumbnail_large;
} else {
$vimeo_thumbnail = str_replace('_640.jpg', '_1280.jpg', $vimeo_thumbnail_large); // replace the size with the size we want
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment