You are here

function lazy_field_formatter_settings_summary_alter in Lazy-load 8.3

Same name and namespace in other branches
  1. 8 lazy.module \lazy_field_formatter_settings_summary_alter()
  2. 8.2 lazy.module \lazy_field_formatter_settings_summary_alter()

Implements hook_field_formatter_settings_summary_alter().

File

./lazy.module, line 131
Module file for Lazy-load.

Code

function lazy_field_formatter_settings_summary_alter(&$summary, $context) {
  if (in_array($context['formatter']
    ->getPluginId(), lazy_field_formatters(), TRUE) && $context['formatter']
    ->getThirdPartySetting('lazy', 'lazy_image', FALSE)) {
    $summary[] = t('Lazy-loading enabled');
    if ($context['formatter']
      ->getThirdPartySetting('lazy', 'placeholder_style', FALSE)) {
      $image_style = \Drupal::entityTypeManager()
        ->getStorage('image_style')
        ->load($context['formatter']
        ->getThirdPartySetting('lazy', 'placeholder_style', FALSE));
      $summary[] = t('Lazy placeholder image style: @name.', [
        '@name' => $image_style
          ->label(),
      ]);
      if ($context['formatter']
        ->getThirdPartySetting('lazy', 'data_uri', FALSE)) {
        $summary[] = t('Lazy placeholder image is embedded via data URI.');
      }
    }
  }
}