You are here

function oembed_preprocess_file_entity in oEmbed 7

Same name and namespace in other branches
  1. 8 oembed.module \oembed_preprocess_file_entity()
  2. 7.0 oembed.module \oembed_preprocess_file_entity()

Implement hook_preprocess_file_entity().

File

./oembed.module, line 580
Core functionality for oEmbed

Code

function oembed_preprocess_file_entity(&$vars, $hook) {
  if (isset($vars['file']->metadata['oembed'])) {
    $vars['oembed_response'] = $embed = $vars['file']->metadata['oembed'];
    $vars['classes_array'][] = 'oembed-' . $embed['type'];
    if (strpos($embed['provider'], ':')) {
      list($parent, $child) = explode(':', $embed['provider'], 2);
      $vars['classes_array'][] = 'oembed-' . $parent;
      $vars['classes_array'][] = 'oembed-' . $child;
    }
    else {
      $vars['classes_array'][] = 'oembed-' . $embed['provider'];
    }
    $vars['title_attributes_array']['class'][] = 'oembed-title';

    // This conflicts with default file_entity.tpl.php which hardcodes a class attribute.
    $vars['content_attributes_array']['class'][] = 'oembed-content';
  }
}