You are here

function youtube_build_thumbnail_uri in YouTube Field 8

Same name and namespace in other branches
  1. 7 youtube.inc \youtube_build_thumbnail_uri()

Builds the URI to a given thumbnail or the module's thumbnail directory.

Parameters

string $video_id: (optional) The video ID to build the thumbnail URI for.

Return value

string If a $video_id was supplied, the URI to that video's thumbnail. Otherwise the URI to the module's thumbnail directory.

4 calls to youtube_build_thumbnail_uri()
template_preprocess_youtube_thumbnail in ./youtube.module
Prepares variables for the YouTube Thumbnail template.
youtube_get_remote_image in ./youtube.module
Retrieves the thumbnail image for a given video from YouTube.
youtube_thumb_delete_all in ./youtube.module
Deletes all existing thumbnail image files.
youtube_tokens in ./youtube.module
Implements hook_tokens().

File

./youtube.module, line 416
Youtube field module adds a field for YouTube videos.

Code

function youtube_build_thumbnail_uri($video_id = NULL) {
  $youtube_thumb_dir = \Drupal::config('youtube.settings')
    ->get('youtube_thumb_dir');
  $youtube_thumb_dir = empty($youtube_thumb_dir) ? 'youtube' : $youtube_thumb_dir;
  $youtube_thumb_uri = file_build_uri($youtube_thumb_dir);
  if ($video_id) {
    return $youtube_thumb_uri . '/' . $video_id . '.jpg';
  }
  return $youtube_thumb_uri;
}