You are here

function hook_blazy_base_settings_alter in Blazy 7

Same name and namespace in other branches
  1. 8.2 blazy.api.php \hook_blazy_base_settings_alter()
  2. 8 blazy.api.php \hook_blazy_base_settings_alter()

Alters blazy-related formatter form options to make site-builders happier.

A less robust alternative to third party settings to pass the options to blazy-related formatters within the designated compact form. While third party settings offer more fine-grained control over a specific formatter, this offers a swap to various blazy-related formatters at one go. Any class extending \Drupal\blazy\BlazyDefault will be capable to modify both form and UI options at one go.

This requires 4 things: option definitions (this alter), schema, extended forms, and front-end implementation of the provided options which can be done via regular hook_preprocess().

In addition to the schema, implement hook_blazy_complete_form_element_alter() to provide the actual extended forms, see far below. And lastly, implement the options at front-end via hook_preprocess().

Parameters

array $settings: The settings being modified.

array $context: The array containing class which defines or limit the scope of the options.

Related topics

1 invocation of hook_blazy_base_settings_alter()
BlazyDefault::baseSettings in src/BlazyDefault.php
Returns basic plugin settings: text, image, file, entities with grids.

File

./blazy.api.php, line 260
Hooks and API provided by the Blazy module.

Code

function hook_blazy_base_settings_alter(array &$settings, array $context = []) {

  // One override for both various Slick field formatters and Slick views style.
  // SlickDefault extends BlazyDefault, hence capable to modify/ extend options.
  // These options will be available at many Slick formatters at one go.
  if ($context['class'] == 'Drupal\\slick\\SlickDefault') {
    $settings += [
      'color' => '',
      'arrowpos' => '',
      'dotpos' => '',
    ];
  }
}