You are here

public static function Blazy::lazyAttributes in Blazy 8.2

Same name and namespace in other branches
  1. 7 src/Blazy.php \Drupal\blazy\Blazy::lazyAttributes()

Defines attributes, builtin, or supported lazyload such as Slick.

These attributes can be applied to either IMG or DIV as CSS background. The [data-(src|lazy)] attributes are applivable for (Responsive) image. While [data-src] is reserved by Blazy, [data-lazy] by Slick.

Parameters

array $attributes: The attributes being modified.

array $settings: The given settings.

Overrides BlazyInterface::lazyAttributes

3 calls to Blazy::lazyAttributes()
Blazy::imageAttributes in src/Blazy.php
Modifies $variables to provide optional (Responsive) image attributes.
BlazyManager::buildImage in src/BlazyManager.php
Build out image, or anything related, including cache, CSS background, etc.
BlazyManager::buildResponsiveImage in src/BlazyManager.php
Build out Responsive image.

File

src/Blazy.php, line 261

Class

Blazy
Provides common blazy utility static methods.

Namespace

Drupal\blazy

Code

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

  // Slick has its own class and methods: ondemand, anticipative, progressive.
  // @todo remove this condition once sub-modules have been aware of preview.
  if (empty($settings['is_preview'])) {
    $attributes['class'][] = $settings['lazy_class'];
    $attributes['data-' . $settings['lazy_attribute']] = $settings['image_url'];
  }
}