You are here

function fitvids_init in FitVids 6

Include the FitVids.js script on every page

File

./fitvids.module, line 83
Includes the FitVids.js jQuery plugin for fluid width video embeds.

Code

function fitvids_init() {
  $installed = file_exists(drupal_get_path('module', 'fitvids') . '/jquery.fitvids.js');
  if (!$installed) {
    return;
  }
  drupal_add_js(drupal_get_path('module', 'fitvids') . '/jquery.fitvids.js', 'module');

  // TODO User should be able to choose which paths this should/shouldn't run on
  $fitvids_selectors = variable_get('fitvids_selectors', DEFAULT_REGIONS);
  $fitvids_selectors_array = explode(PHP_EOL, $fitvids_selectors);
  $inline_code = '// Output by FitVids module' . PHP_EOL;
  foreach ($fitvids_selectors_array as $selector) {
    $selector = trim($selector);
    $inline_code .= 'jQuery("' . $selector . '").fitVids();' . PHP_EOL;
  }
  drupal_add_js($inline_code, 'inline', 'footer');
}