You are here

public function ThemePreprocess::attachLibrary in Image Lazyloader 8

Attaches the Lazyloader library to a render array.

Parameters

array $vars: The render array.

Return value

array The render array with added library.

File

src/ThemePreprocess.php, line 38

Class

ThemePreprocess
Class ThemePreprocess.

Namespace

Drupal\lazyloader

Code

public function attachLibrary(array $vars) {
  $config = $this->configFactory
    ->get('lazyloader.configuration');
  if (!$config
    ->get('enabled')) {
    return $vars;
  }
  $vars['#attached']['library'][] = $this
    ->determineLibraryToAttach();
  return $vars;
}