You are here

function blazy_blazy_attach_alter in Blazy 8

Implements hook_blazy_attach_alter().

File

./blazy.module, line 118
Provides basic Blazy integration for lazy loading and multi-serving images.

Code

function blazy_blazy_attach_alter(array &$load, $attach = []) {
  if (!empty($attach['colorbox'])) {

    // Uninstalling colorbox without updating fields might break, bail out.
    if (function_exists('colorbox_theme')) {
      $dummy = [];
      \Drupal::service('colorbox.attachment')
        ->attach($dummy);
      $load = isset($dummy['#attached']) ? NestedArray::mergeDeep($load, $dummy['#attached']) : $load;
      $load['library'][] = 'blazy/colorbox';
      unset($dummy);
    }
  }
}