Problem/Motivation
In getOriginalThumbnailPath() function of MediaYouTubeStreamWrapper class (includes/MediaYouTubeStreamWrapper.inc),
From Line 24,
$thumbname = drupal_tempnam('temporary://', 'youtube');
$response = drupal_http_request('http://img.youtube.com/vi/' . $v . '/maxresdefault.jpg');
if (!isset($response->error)) {
file_unmanaged_save_data($response->data, $thumbname, $replace = FILE_EXISTS_REPLACE);
}
if ((filesize($thumbname)) == 0) {
return 'http://img.youtube.com/vi/' . $v . '/0.jpg';
}
else {
return 'http://img.youtube.com/vi/' . $v . '/maxresdefault.jpg';
}
Used temporary path to save the HD thumbnail data. After saving used filesize function to check image exist or not.
So, every time this function generate a temp file and it never deleted.
For that reason the temporary folder become filled up quickly for a busy site.
Proposed resolution
No need to save the response data to a temporary file to check its size. We can easily checked the status code of the response. If the response code is 200 then HD thumbnail exist otherwise not.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#5 | media_youtube-original-thumbnail-check-bug-2475883-5.patch | 1.53 KB | Devin Carlson |
#2 | media_youtube-original-thumbnail-check-bug-2475883-2.patch | 1.24 KB | saniyat |
Comments
Comment #1
saniyat CreditAttribution: saniyat commentedPatch file.
Comment #2
saniyat CreditAttribution: saniyat commentedSorry, wrong patch.
Comment #3
saniyat CreditAttribution: saniyat commentedComment #4
magicmyth CreditAttribution: magicmyth commentedI ran into this same issue a couple weeks ago when I recently updated the module. It almost crashed a site when the Drupal's temporary directory had filled to over 60 gigabytes, filling the partition space. I've been running this patch for near on two weeks now and my temporary directory has remained an expected size.
Thanks for the patch saniyat.
Comment #5
Devin Carlson CreditAttribution: Devin Carlson commentedThanks for the patch!
I think that we should use the thumbnail provided by the oEmbed standard while we're modifying this.
Comment #6
Devin Carlson CreditAttribution: Devin Carlson commentedTested #5 and committed to Media: YouTube 7.x-3.x.
Comment #9
westis CreditAttribution: westis at Öppna Kanalen Växjö commentedIs this being worked on? I mean, with the current solution we don't get the HD resolution thumbnails. What can we do to get them back, while still avoiding the issue that the temporary patch is addressing?
Comment #10
Anima CreditAttribution: Anima commentedAfter this update File entity сan not generate YouTube Preview Image
Comment #11
shelaneIn a page generated by a view, I am seeing the thumbnail src looking like: /%3Fitok%3D9WmwD7I6 at the root of the site, which should never be the case. Other images (non-videos) have paths that look like: /sites/default/files/styles/article_thumbnail/public/field/image/reactor875x500px.jpg?itok=VWVP6RYr which is more in line with what I expect to see.
I'm not sure when this broke as most of our stories don't have YouTube Videos as leading images. However, there is definitely something broken.
Comment #12
froboyI can also confirm that this patch breaks thumbnail generation. With media_youtube on the latest dev thumbnails are broken, whether they're generated from an image style or use "original image". For me, this manifests as the following error in watchdog:
Reverting MediaYouTubeStreamWrapper.inc to the previous version fixes thumbnails for original image, media_thumbnail, and a custom image style. I've tried reverting a few pieces of the change, but I can't figure out exactly where things are breaking.