You are here

social_lazy_loading.module in Open Social 8.6

Provides basic Blazy integration for lazy loading and multi-serving images.

File

modules/custom/social_lazy_loading/social_lazy_loading.module
View source
<?php

/**
 * @file
 * Provides basic Blazy integration for lazy loading and multi-serving images.
 */

/**
 * Implements hook_preprocess().
 */
function social_lazy_loading_preprocess_node(&$variables) {

  /** @var \Drupal\node\Entity\Node $node */
  $node = $variables['node'];
  if ($node
    ->getType() === 'landing_page') {

    // Add lazy loading to landing pages.
    // Make sure it will be reactivated.
    $variables['content']['#attached']['library'][] = 'social_lazy_loading/lazy_load_reactivate';
  }
}

Functions