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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

saniyat’s picture

saniyat’s picture

Sorry, wrong patch.

saniyat’s picture

Status: Active » Needs review
magicmyth’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

Devin Carlson’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Needs review
FileSize
1.53 KB

Thanks for the patch!

I think that we should use the thumbnail provided by the oEmbed standard while we're modifying this.

Devin Carlson’s picture

Status: Needs review » Fixed

Tested #5 and committed to Media: YouTube 7.x-3.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

westis’s picture

Is 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?

Anima’s picture

After this update File entity сan not generate YouTube Preview Image

shelane’s picture

Status: Closed (fixed) » Needs work

In 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.

froboy’s picture

I 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:

Source image at public://media-youtube/DgjaeioWEnA.jpg not found while trying to generate derivative image at public://styles/media_thumbnail/public/media-youtube/DgjaeioWEnA.jpg.A.jpg.

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.