function lazy_settings_update in Lazy-load 8
Same name and namespace in other branches
- 8.2 lazy.module \lazy_settings_update()
Update `lazy.settings.image_fields` value with currently enabled options.
Parameters
array $image_fields:
2 calls to lazy_settings_update()
File
- ./
lazy.module, line 211 - Module file for Lazy-load.
Code
function lazy_settings_update(array $image_fields) {
$current_image_fields = \Drupal::config('lazy.settings')
->get('image_fields');
if (empty($current_image_fields)) {
$current_image_fields = [];
}
$fields = array_merge($current_image_fields, $image_fields);
foreach ($fields as $field_name => $bool_value) {
if (!$bool_value) {
unset($fields[$field_name]);
}
}
\Drupal::service('config.factory')
->getEditable('lazy.settings')
->set('image_fields', $fields)
->save();
}