You are here

function lazy_page_build in Lazy-load 7

Implements hook_page_build().

File

./lazy.module, line 242
Module file for Lazy-load.

Code

function lazy_page_build(&$page) {
  if (!variable_get('lazy_prefer_native')) {
    $path = drupal_get_path('module', 'lazy');
    $page['page_bottom']['lazy'] = array(
      '#attached' => array(),
    );
    $attached =& $page['page_bottom']['lazy']['#attached'];
    $attached['js'][] = array(
      'data' => array(
        'lazy' => array(
          'errorClass' => variable_get('lazy_filter_errorClass'),
          'loadInvisible' => variable_get('lazy_filter_loadInvisible'),
          'offset' => (int) variable_get('lazy_filter_offset'),
          'saveViewportOffsetDelay' => (int) variable_get('lazy_filter_saveViewportOffsetDelay'),
          'selector' => '.' . variable_get('lazy_filter_selector'),
          'src' => variable_get('lazy_filter_src'),
          'successClass' => variable_get('lazy_filter_successClass'),
          'validateDelay' => (int) variable_get('lazy_filter_validateDelay'),
        ),
      ),
      'type' => 'setting',
    );
    $attached['libraries_load'][] = array(
      'blazy',
    );
    $attached['js'][$path . '/lazy.js'] = array(
      'every_page' => TRUE,
    );
  }
}