You are here

function responsive_imagemaps_init in Responsive Image Maps 7

Implements hook_init().

File

./responsive_imagemaps.module, line 101

Code

function responsive_imagemaps_init() {
  $load_responsive_imagemaps = variable_get('responsive_imagemaps_visibility', RESPONSIVE_IMAGEMAPS_ALWAYS);

  // Match path if necessary.
  if ($load_responsive_imagemaps == RESPONSIVE_IMAGEMAPS_LISTED) {

    // Convert path to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $pages = drupal_strtolower(variable_get('responsive_imagemaps_pages', ''));

    // Convert the Drupal path to lowercase
    $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));

    // Compare the lowercase internal and lowercase path alias (if any).
    $load_responsive_imagemaps = drupal_match_path($path, $pages);
    if ($path != $_GET['q']) {
      $load_responsive_imagemaps = $load_responsive_imagemaps || drupal_match_path($_GET['q'], $pages);
    }
  }
  if ($load_responsive_imagemaps) {
    libraries_load('responsive-imagemaps');
    drupal_add_js(drupal_get_path('module', 'responsive_imagemaps') . '/responsive_imagemaps.js', array(
      'scope' => 'footer',
    ));
  }
}