In the youtube_tokens() function, there's a test to see if the YouTube thumbnail already exists:

            $file_uri = youtube_build_thumbnail_uri($video_id);
            $file_url = file_create_url($file_uri);
            if (file_exists($file_url) || youtube_get_remote_image($video_id)) {

It believe that it should be $file_uri that's passed to file_exists(), not $file_url.

Because the file_exists() is always failing, the thumbnail image is being recreated on every call.

In the general run of affairs this is fine, and wouldn't be noticed; in our case, however, with a high-traffic site where the tokenized image was being called several times a second, it dramatically increased the load on our server.

I've attached a patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

reinvented created an issue. See original summary.

reinvented’s picture

guschilds’s picture

Status: Active » Needs review
Gold’s picture

Status: Needs review » Reviewed & tested by the community

Tested this with a number of nodes. The token call does indeed always fail on the $file_url.

The patch allows this to work as desired.

imyaro’s picture

Assigned: Unassigned » imyaro

  • zvse committed 7a97367 on 7.x-1.x authored by reinvented
    Issue #2902588 by reinvented, zvse: youtube_tokens() regenerates...
imyaro’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch, works OK

Status: Fixed » Closed (fixed)

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