Created
October 26, 2012 22:38
-
-
Save germanny/3961968 to your computer and use it in GitHub Desktop.
Get Vimeo 1280px poster image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
Is this still working?
Works:
http://b.vimeocdn.com/ts/235/662/23566238_100.jpg
http://b.vimeocdn.com/ts/235/662/23566238_200.jpg
http://b.vimeocdn.com/ts/235/662/23566238_640.jpg
Doesn't work:
http://b.vimeocdn.com/ts/235/662/23566238_1280.jpg