I am getting this error " Fatal error: Call to a member function renderThumbnail() on a non-object in /home/leopathu/Public/project/modules/video/src/Plugin/Field/FieldFormatter/VideoEmbedThumbnailFormatter.php on line 73 " while creating views with the video field thumbnail formatter

CommentFileSizeAuthor
#8 patch.diff1.76 KBhypertext200
#3 11-15-2016 2-08-34 PM.jpg110.96 KBchaitanya17

Comments

leopathu created an issue. See original summary.

chaitanya17’s picture

Assigned: Unassigned » chaitanya17
chaitanya17’s picture

StatusFileSize
new110.96 KB

@eopathu,

I have tried to reproduce scenario, created video field, added Youtube URL and in view used Embedded Video Thumbnail, Thumbnail is rendered properly without any error.

Let me know which video type you have embedded.

chaitanya17’s picture

Status: Active » Needs review
leopathu’s picture

Status: Needs review » Needs work

In my case, some node has video in the field and some node doesn't have any value in the video field. Try with both with video and without video, you can regenerate the issue :)

chaitanya17’s picture

leopathu,

Share Detail Content type manage field screenshot and screenshot of detail page.
Also give details of video format you are uploading.

NewZeal’s picture

I have encountered this problem using Vimeo.

Notice: Trying to get property of non-object in Drupal\video\Plugin\video\Provider\Vimeo->getRemoteThumbnailUrl()
Warning: file_get_contents(http://vimeo.com/api/v2/video/158971633.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in Drupal\video\Plugin\video\Provider\Vimeo->getRemoteThumbnailUrl() 
GuzzleHttp\Exception\RequestException: Error creating resource: [message] fopen(http:): failed to open stream: No such file or directory [file] 

Because it is a fatal error I get WSOD so have made some temporary modifications to enable the page to load. The script really ought to handle unmet expectations in a nice way:

ProviderPluginBase.php

  protected function downloadThumbnail() {
    $local_uri = $this->getLocalThumbnailUri();
    if (!file_exists($local_uri)) {
      $thumb_dir = $this->getUploadLocation();
      file_prepare_directory($thumb_dir, FILE_CREATE_DIRECTORY);
      $remote_url = $this->getRemoteThumbnailUrl();
      if ($remote_url) {
        $thumbnail = $this->httpClient->request('GET', $this->getRemoteThumbnailUrl());
        file_unmanaged_save_data((string) $thumbnail->getBody(), $local_uri);
      }
    }
  }

And in Vimeo.php

  public function getRemoteThumbnailUrl() {
    $data = $this->getVideoMetadata();
    $video_data = json_decode(file_get_contents('http://vimeo.com/api/v2/video/' . $data['id'] . '.json'));
    if (is_object($video_data[0])) {
      return $video_data[0]->thumbnail_large;
    }
    return FALSE;
  }

Obviously each provider plugin needs to return false if the thumbnail fails.

Thanks

hypertext200’s picture

StatusFileSize
new1.76 KB

This should fix the issue.

  • heshanlk committed 4cd1a33 on 8.x-1.x authored by leopathu
    Issue #2819781 by heshanlk, chaitanya17, leopathu: Getting Error
    
hypertext200’s picture

Status: Needs work » Fixed

  • heshanlk committed 14937e6 on 8.x-1.x
    Revert "Issue #2819781 by heshanlk, chaitanya17, leopathu: Getting Error...

  • heshanlk committed 3abcdc9 on 8.x-1.x authored by New Zeal
    Issue #2819781 by heshanlk, chaitanya17, leopathu, New Zeal: Getting...
NewZeal’s picture

Thanks. Awesome quick response.

You'd need to do the same fix for each of the video providers:

public function getRemoteThumbnailUrl() {
    $data = $this->getVideoMetadata();
    $video_data = json_decode(file_get_contents('http://[provider name]/path/to/video/' . $data['id'] . '.[suffix]'));
    if (is_object($video_data[0])) {
      return $video_data[0]->thumbnail_large;
    }
    return FALSE;
  }

Status: Fixed » Closed (fixed)

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