protected function ProviderPluginBase::downloadThumbnail in Video 8.2
Same name and namespace in other branches
- 8 src/ProviderPluginBase.php \Drupal\video\ProviderPluginBase::downloadThumbnail()
Download the remote thumbnail to the local file system.
1 call to ProviderPluginBase::downloadThumbnail()
File
- src/ProviderPluginBase.php, line 121 
Class
- ProviderPluginBase
- A base for the provider plugins.
Namespace
Drupal\videoCode
protected function downloadThumbnail() {
  $local_uri = $this
    ->getLocalThumbnailUri();
  if (!file_exists($local_uri)) {
    $thumb_dir = $this
      ->getUploadLocation();
    \Drupal::service('file_system')
      ->prepareDirectory($thumb_dir, FileSystemInterface::CREATE_DIRECTORY);
    $remote_url = $this
      ->getRemoteThumbnailUrl();
    if ($remote_url) {
      $thumbnail = $this->httpClient
        ->request('GET', $this
        ->getRemoteThumbnailUrl());
      \Drupal::service('file_system')
        ->saveData((string) $thumbnail
        ->getBody(), $local_uri);
    }
  }
}