You are here

function lazy_is_enabled in Lazy-load 8.2

Same name and namespace in other branches
  1. 8 lazy.module \lazy_is_enabled()

Callback function to check whether lazy is enabled in any text-formats.

Return value

mixed Lazy configuration object if enabled, false otherwise.

2 calls to lazy_is_enabled()
LazyForm::buildForm in src/Form/LazyForm.php
Form constructor.
lazy_page_attachments in ./lazy.module
Implements hook_page_attachments().

File

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

Code

function lazy_is_enabled() {
  $status = [];
  $filters = filter_formats();
  foreach ($filters as $key => $filter) {
    if ($filter
      ->status() && isset($filter
      ->getDependencies()['module']) && in_array('lazy', $filter
      ->getDependencies()['module'], TRUE)) {
      $status[$key] = TRUE;
    }
  }
  $config = \Drupal::config('lazy.settings')
    ->get();
  $image_fields = $config['image_fields'];
  if (is_array($image_fields)) {
    foreach ($image_fields as $field_name => $bool_value) {
      if ($bool_value) {
        $status[$field_name] = TRUE;
      }
    }
  }
  $config['status'] = $status;
  return count($status) ? $config : FALSE;
}