You are here

function amp_preprocess_amp_video in Accelerated Mobile Pages (AMP) 7

Implements hook_preprocess_amp_video().

File

./amp.module, line 236

Code

function amp_preprocess_amp_video(&$variables) {
  $file = $variables['file'];

  // Set the SRC from the file URI if available.
  if (empty($variables['src']) && is_object($file)) {
    $variables['src'] = file_create_url($file->uri);
  }

  // amp-video can only be displayed if the src for the video is https.
  $variables['scheme'] = file_uri_scheme($variables['src']);

  // Use the description as the title text if available.
  if (empty($variables['description']) && is_object($file)) {
    $title_text = $file->filename;
  }
  else {
    $title_text = check_plain($variables['description']);
  }
  $variables['video_attributes_array']['title'] = $title_text;

  // Set the fallback text.
  if (empty($variables['fallback_text'])) {
    $variables['fallback_text'] = t("This browser does not support the video element.");
  }
}