Skip to content

Instantly share code, notes, and snippets.

@pragmatic-web
Created August 22, 2013 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pragmatic-web/6306792 to your computer and use it in GitHub Desktop.
Save pragmatic-web/6306792 to your computer and use it in GitHub Desktop.
Getting a specific Vimeo thumbnail size via cURL/PHP building on http://www.soapboxdave.com/2010/04/getting-the-vimeo-thumbnail/
function vimeo_thumb_size( $id, $size = 'large' ) {
// Sanitize the variables
$id = esc_attr( $id );
$size = esc_attr( $size );
// Stop if no video ID entered
if ( empty( $id ) )
return 'Error - no video ID specified';
if (!function_exists('curl_init')) die('cURL is not installed!');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://vimeo.com/api/v2/video/$id.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = unserialize(curl_exec($ch));
$output = $output[0];
curl_close($ch);
if ( 'small' == $size ) {
return $output["thumbnail_small"];
} elseif ( 'medium' == $size ) {
return $output["thumbnail_medium"];
} else {
return $output["thumbnail_large"];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment