You are here

function lazy_form_entity_view_display_edit_form_alter in Lazy-load 8.2

Same name and namespace in other branches
  1. 8 lazy.module \lazy_form_entity_view_display_edit_form_alter()

Implements hook_form_FORM_BASE_ID_alter().

File

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

Code

function lazy_form_entity_view_display_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $entity_type = $form['#entity_type'];
  $bundle = $form['#bundle'];
  $image_fields = [];
  if ($fields = $form_state
    ->getValue('fields')) {
    foreach ($fields as $field_name => $field) {
      if (in_array($field['type'], lazy_field_types(), TRUE) && isset($field['settings_edit_form']['third_party_settings']['lazy']['lazy_image'])) {
        $route_match = \Drupal::service('current_route_match');
        $view_mode = $route_match
          ->getParameter('view_mode_name');
        $image_fields["{$entity_type}--{$bundle}--{$view_mode}--{$field_name}"] = (bool) $field['settings_edit_form']['third_party_settings']['lazy']['lazy_image'];
      }
    }
  }
  lazy_settings_update($image_fields);
}