You are here

public static function Blazy::thumbnailAttributes in Blazy 8

Modifies $variables to provide optional thumbnail attributes.

With CSS background, IMG may be empty, add thumbnail to the container. Supports unique thumbnail different from main image, such as logo for thumbnail and main image for company profile.

1 call to Blazy::thumbnailAttributes()
Blazy::buildAttributes in src/Blazy.php
Prepares variables for blazy.html.twig templates.

File

src/Blazy.php, line 217

Class

Blazy
Implements BlazyInterface.

Namespace

Drupal\blazy

Code

public static function thumbnailAttributes(array &$variables) {
  $settings = $variables['settings'];
  $attributes =& $variables['attributes'];
  if (!empty($settings['thumbnail_uri'])) {
    $attributes['data-thumb'] = file_url_transform_relative(file_create_url($settings['thumbnail_uri']));
  }
  elseif (!empty($settings['thumbnail_style'])) {
    $attributes['data-thumb'] = ImageStyle::load($settings['thumbnail_style'])
      ->buildUrl($settings['uri']);
  }
}