You are here

public static function Blazy::lazyAttributes in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Blazy.php \Drupal\blazy\Blazy::lazyAttributes()
1 call to Blazy::lazyAttributes()
BlazyManager::buildImage in src/BlazyManager.php
Build out image, or anything related, including cache, CSS background, etc.

File

src/Blazy.php, line 166

Class

Blazy
Implements BlazyInterface.

Namespace

Drupal\blazy

Code

public static function lazyAttributes(array &$attributes, array $settings = []) {

  // Defines attributes, builtin, or supported lazyload such as Slick.
  $attributes['class'][] = $settings['lazy_class'];
  $attributes['data-' . $settings['lazy_attribute']] = $settings['image_url'];

  // Support browser native lazy loading as per 8/2019 specific to Chrome 76+.
  // See https://web.dev/native-lazy-loading/
  $attributes['loading'] = 'lazy';
}