-
-
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/)
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
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