Révision 58344a8d
Ajouté par Assos Assos il y a presque 9 ans
drupal7/sites/all/modules/media_youtube/includes/MediaYouTubeStreamWrapper.inc | ||
---|---|---|
18 | 18 |
|
19 | 19 |
function getOriginalThumbnailPath() { |
20 | 20 |
$parts = $this->get_parameters(); |
21 |
$v = check_plain($parts['v']);
|
|
22 |
// Attempt to pull a HD thumbnail from YouTube. If it exists pass it on
|
|
23 |
// otherwise pass on the smaller one.
|
|
24 |
$thumbname = drupal_tempnam('temporary://', 'youtube');
|
|
25 |
$response = drupal_http_request('http://img.youtube.com/vi/' . $v . '/maxresdefault.jpg'); |
|
21 |
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v']));
|
|
22 |
$external_url = file_create_url($uri);
|
|
23 |
$oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
|
|
24 |
$response = drupal_http_request($oembed_url);
|
|
25 |
|
|
26 | 26 |
if (!isset($response->error)) { |
27 |
file_unmanaged_save_data($response->data, $thumbname, $replace = FILE_EXISTS_REPLACE); |
|
28 |
} |
|
29 |
if ((filesize($thumbname)) == 0) { |
|
30 |
return 'http://img.youtube.com/vi/' . $v . '/0.jpg'; |
|
27 |
$data = drupal_json_decode($response->data); |
|
28 |
return $data['thumbnail_url']; |
|
31 | 29 |
} |
32 | 30 |
else { |
33 |
return 'http://img.youtube.com/vi/' . $v . '/maxresdefault.jpg'; |
|
31 |
throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})"); |
|
32 |
return; |
|
34 | 33 |
} |
35 | 34 |
} |
36 | 35 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules