Skip to content

Instantly share code, notes, and snippets.

@ASDAFF
Forked from pragmatic-web/gist:6306792
Last active November 18, 2015 21:38
Show Gist options
  • Save ASDAFF/bd37d1cdbf09faa85e30 to your computer and use it in GitHub Desktop.
Save ASDAFF/bd37d1cdbf09faa85e30 to your computer and use it in GitHub Desktop.
Получение миниатюры с конкретным размером Vimeo с помощью cURL/PHP (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