The thumbnail generation for private videos on Vimeo does not load the images because the thumbnail is loaded via Simple API instead of the Advanced API that loads the images via oEmbed.
As quoted from vimeo for the same issue in Media:Vimeo in http://drupal.org/node/1587686:

The Simple API is for public data only. If your videos are private, you will need to use the Advanced API. If your video is set to hide from vimeo.com, but is embeddable, you may also be able to use oEmbed.

Attached is a patch that use the Advanced API for image loading.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spuky’s picture

Status: Active » Reviewed & tested by the community

Code makes sense and running into the problem it works so I set it to rtbc

mrweiner’s picture

Status: Reviewed & tested by the community » Needs work

This does result in the thumbnails being correctly generated. However, its throwing this error in various places involving the field.

Strict warning: Only variables should be passed by reference in template_preprocess_video_embed_field_embed_code() (line 355 of /.../sites/all/modules/video_embed_field/video_embed_field.module).

dpliscoff’s picture

Status: Needs work » Active

Hi mrwiner,
I' not able to reproduce the error. Can you give me some hints to check it?

mrweiner’s picture

I can try to, but there doesn't seem to be a really solid way for me to reproduce it.

When I just went to the site, it popped up on the home page. I'm assuming because right now it's the default front page with a feed of content, and the content displayed in that feed contains video embed fields.

It also pops up for me when I visit the edit form for a node with a populated video embed field, as well as in the form for a view that utilizes the thumbnails. For the most parts it seems like the error is thrown once, and then doesn't display unless content is re-saved. So if I save a node that has a thumbnail and go to edit it, the error doesn't show until after I save it again, at which point the error shows again on the edit page. Re-saving did not cause the homepage error to show again, so I don't know how often it refreshes on there. Not sure when it decides to pop up on the view edit page.

Nothing seems to be affected by the error besides the fact that it's there, though.

dpliscoff’s picture

I don't know if this is directly related with the patch, but following this http://drupal.stackexchange.com/questions/6322/strict-warning-only-variables-should-be-passed-by-reference-in-include maybe changing how the call to drupal_render can help. In vimeo_embed_field.module line 355, replace

    $variables['embed_code'] = drupal_render(call_user_func($handler['function'], $variables['url'], $variables['style_settings']));

with

    $embed = call_user_func($handler['function'], $variables['url'], $variables['style_settings']);
    $variables['embed_code'] = drupal_render($embed);

Again, I'm not able to make the warning appear in the views or administration pages, so I'm guessing a bit here.

mrweiner’s picture

Status: Active » Reviewed & tested by the community

Yup, changing that line that seems to have done the trick. Not sure how to create patches though, so that's on you. :)

EDIT: Woops, accidentally changed the status. I guess it's pre-emptive, but if a patch with the change is submitted then the status will be accurate.

dpliscoff’s picture

Too late, this issue is already fixed on 7.x-2.x-dev :). Check https://drupal.org/node/1913720

vinmassaro’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.13 KB

@dpliscoff: Tested your patch and it works great. I've updated the patch since it wasn't applying cleanly for me, and gave you attribution. Setting back to needs review for a final check on this patch. This is against 7.x-2.x HEAD. Thanks!

vinmassaro’s picture

Updated patch that removes some whitespace.

dpliscoff’s picture

Status: Needs review » Reviewed & tested by the community

@vinmassaro Thanks. Tested your patch on 7.x-2.x-dev and works ok. Back to RTBC.

gfed’s picture

Private videos can sometimes have urls where there are multiple other codes and variables. This addresses this issue. Seems to be working fine on my end.

Khalor’s picture

Version: 7.x-2.0-beta5 » 7.x-2.x-dev

The current stock 7.x-2.x-dev branch doesn't fix the issue.

The patch in #9 applies cleanly agains the current 7.x-2.x-dev version and fixes the issue.
Let's get this committed?

(The patch in #11 didn't apply cleanly)

JenniferRader’s picture

Issue summary: View changes

Thanks for this thread...it was super helpful for me. Patch #9 won't apply to beta7, but of course can be applied manually, which worked great.

Is it likely this will get committed on a future release?

illeace’s picture

I have only done a small amount of testing, but so far patch #11 works for me. I had to apply it manually, though. Here's a re-roll of that patch that will apply to the latest 7.x-2.x-dev release.

stilblütler’s picture

i applied patch #14 to file "video_embed_field.handlers.inc" of video_embed_field-7.x-2.x-dev (Date: 2014-Jul-27).
that didn’t work, because in "function _video_embed_field_get_vimeo_id($url)" there were missing the following two lines

+    return (int) $vid_id;
+  } 

before the closing of the the function with:

  return FALSE;
}

---
after correction the function, starting at line 431 in the file "video_embed_field.handlers.inc", reads as follows:

function _video_embed_field_get_vimeo_id($url) {
  $pos = strripos($url, '/');
  if ($pos != FALSE) {
    $matches = "";
    $vid_id = "";
    preg_match_all('!\d+!', $url, $matches);
    foreach($matches as $i => $row) {
      foreach($row as $b => $digits ) {
        if(strlen($digits) >= 8) {
          $vid_id = $digits;
        }
      }
    }
    return (int) $vid_id;
  } 
  return FALSE;
}

the thumbnails of links to private vimeo videos appear after re-saving the affected nodes.

illeace’s picture

stilblütler is quite right. Thanks for catching that mistake! Here's another revised patch file.

plopesc’s picture

Status: Reviewed & tested by the community » Needs work

Hello
Nice catch I tested patch #13 and works fine for public and not presento on vimeo videos, but not for private ones because $video['thumbnail_url'] is not always set. So it should be something like this:

$response = drupal_http_request('http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/'. $id);
if (!isset($response->error)) {
  $video = json_decode($response->data, TRUE);
  if (isset($video['thumbnail_url'])) {
    $info['url'] = $video['thumbnail_url'];
  }
}

Path in #16 is missing this part of the patch, so it is incomplete. Moreover, the approach of strlen($digits) >= 8 is not appropriate at all given that there are vimeo videos where the id lenght is minor than 8 digits. IE https://vimeo.com/85. I think that there is a URL pattern for those videos that we could use to extract the URL from there.

Thank you.

pm5’s picture

I have merge the changes in #17 with #14 and #16 to produce a patch against the latest 7.x-2.x-dev release. I can confirm that it works for the public (but not visible on vimeo and embeddable only by our domain) videos on our site.

pm5’s picture

(Posted again caused by HTTP 504.)

I have merge the changes in #17 with #14 and #16 to produce a patch against the latest 7.x-2.x-dev release. I can confirm that it works for the public (but not visible on vimeo and embeddable only by our domain) videos on our site.

pm5’s picture

Oops. The patch I just sent was from our web site repo. Re-send the same patch for the module.

pm5’s picture

Status: Needs work » Needs review
plopesc’s picture

Status: Needs review » Needs work

Hello pm5

Thank you for your patch. However, as i said in #17, strlen($digits) >= 8 is not a valid way to decide which URL parameter should be taken.

Are you sure that Vimeo's documentation does not provide a way to determine the video id from an URL in that format?

Thank you

tte’s picture

Here's a small patch I wrote which should take care of properly identifying a vimeo video's ID by querying the oembed response array. I did some minor cleanups as well.

tte’s picture

Oh, just found out that my previous patch applies against video_embed_field-empty_private_vimeo_thumbnails-1996924-19.patch. Here's another patch which applies against vanilla 7.x-2.0-beta8.

zrpnr’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
3.97 KB

The patch in #24 worked for me, the private video thumbnails load correctly now.
I just re-rolled the patch against 7.x-2.x dev, removed the path to the file.

Didn't make any other changes to speely's code, thanks! Marking RTBC.

bocaj’s picture

I was having this same issue. I applied the patch in #25 and resaved all of the nodes with VBO and it worked perfectly. Would love to see this get commited soon!

Thanks everyone for your work on this!

  • plopesc committed 418d199 on 7.x-2.x authored by speely
    Issue #1996924 by pm5, illeace, speely, vinmassaro, dpliscoff, zrpnr,...
plopesc’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you!

Status: Fixed » Closed (fixed)

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

Leon Kessler’s picture

This commit removes the data_function from the vimeo handler definition, this is an API change (other modules may be using the data_function and the video_data object on the field).
Adding related issue to bring this back in.

mpp’s picture

FYI, this is no longer working.

If a video’s privacy is set to anything other than public, private or password protected, only the embed code, width, and height will be returned.

source: https://developer.vimeo.com/apis/oembed

This would require the new API (developer.vimeo.com/api). See documentation on https://developer.vimeo.com/api/start
So the new API with keys and a token is needed to get a video thumbnail for private video's (https://api.vimeo.com/videos/{video_id}).

joelstein’s picture