diff --git a/core/modules/responsive_image/responsive_image.install b/core/modules/responsive_image/responsive_image.install new file mode 100644 index 0000000..1a64048 --- /dev/null +++ b/core/modules/responsive_image/responsive_image.install @@ -0,0 +1,27 @@ +listAll('filter.format') as $name) { + $config = $config_factory->getEditable($name); + if (!$config->get('filters.filter_responsive_image_style.status')) { + continue; + } + $allowed_html = $config->get('filters.filter_html.settings.allowed_html'); + $matches = []; + if (!empty($allowed_html) && preg_match('/]*)>/', $allowed_html, $matches)) { + $new_attributes = array_filter(explode(' ', $matches[1])); + $new_attributes[] = 'data-responsive-image-style'; + $allowed_html = preg_replace('/]*)>/', '', $allowed_html); + $config->set('filters.filter_html.settings.allowed_html', $allowed_html); + $config->save(); + } + } +} diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 47f6dca..94f27cd 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1808,5 +1808,27 @@ function system_update_8011() { } /** + * Add allowed attributes to existing html filters. + */ +function system_update_8012() { + $config_factory = \Drupal::configFactory(); + foreach ($config_factory->listAll('filter.format') as $name) { + $config = $config_factory->getEditable($name); + if (!$config->get('filters.filter_imagestyle.status')) { + continue; + } + $allowed_html = $config->get('filters.filter_html.settings.allowed_html'); + $matches = []; + if (!empty($allowed_html) && preg_match('/]*)>/', $allowed_html, $matches)) { + $new_attributes = array_filter(explode(' ', $matches[1])); + $new_attributes[] = 'data-image-style'; + $allowed_html = preg_replace('/]*)>/', '', $allowed_html); + $config->set('filters.filter_html.settings.allowed_html', $allowed_html); + $config->save(); + } + } +} + +/** * @} End of "addtogroup updates-8.0.0-beta". */ diff --git a/core/profiles/standard/config/install/filter.format.basic_html.yml b/core/profiles/standard/config/install/filter.format.basic_html.yml index 92224c2..f35869c 100644 --- a/core/profiles/standard/config/install/filter.format.basic_html.yml +++ b/core/profiles/standard/config/install/filter.format.basic_html.yml @@ -15,9 +15,15 @@ filters: status: true weight: -10 settings: - allowed_html: '