You are here

function _lazy_loader_enabled in Image Lazyloader 7

Same name and namespace in other branches
  1. 7.2 lazyloader.module \_lazy_loader_enabled()

Helper function to determine whether the lazyloader is enabled in a page.

Return value

bool

2 calls to _lazy_loader_enabled()
lazyloader_image in ./lazyloader.module
Returns HTML for an image.
lazyloader_page_build in ./lazyloader.module
Implements hook_page_build().

File

./lazyloader.module, line 195
Lazyloader Module

Code

function _lazy_loader_enabled() {

  // Bail if lazyloader is disabled entirely.
  if (!variable_get('lazyloader_enabled', LAZYLOADER_ENABLED)) {
    return FALSE;
  }

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

  // 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).
  $path_match = drupal_match_path($path, $pages);
  if ($path != $_GET['q']) {
    $path_match = $path_match || drupal_match_path($_GET['q'], $pages);
  }
  if (variable_get('lazyloader_exclude_option', LAZYLOADER_EXCLUDE_OPTION) === 'exclude') {
    return !$path_match;
  }
  else {
    return $path_match;
  }
}