You are here

image_lazy_loader.install in Image Lazy Loader 8

Check requirements for lazy loader module.

File

image_lazy_loader.install
View source
<?php

/**
 * @file
 * Check requirements for lazy loader module.
 */

/**
 * Implements hook_requirements().
 *
 * {@inheritdoc}
 */
function image_lazy_loader_requirements($phase) {
  $requirements = [];
  if ($phase == 'install' || $phase == 'runtime') {
    $plugin_detected = file_exists(DRUPAL_ROOT . '/libraries/lozad/dist/lozad.min.js');
    if ($plugin_detected) {
      $requirements['lozad'] = [
        'title' => t('Lozad'),
        'value' => t('Plugin detected'),
        'severity' => REQUIREMENT_OK,
      ];
    }
    else {
      $requirements['lozad'] = [
        'title' => t('Lozad'),
        'value' => t('Plugin not detected'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('Before you can use the Image Lazy Loader module, you need to download the Lozad plugin from Github and place it in /libraries/lozad. Check the README.txt for more information. <a href=":plugin_url">Get the Lozad plugin here</a>.', [
          ':plugin_url' => 'https://github.com/ApoorvSaxena/lozad.js',
        ]),
      ];
    }
  }
  return $requirements;
}

Functions