diff --git a/core/modules/responsive_image/config/install/responsive_image.settings.yml b/core/modules/responsive_image/config/install/responsive_image.settings.yml new file mode 100644 index 0000000..6b5a5f1 --- /dev/null +++ b/core/modules/responsive_image/config/install/responsive_image.settings.yml @@ -0,0 +1 @@ +suppress_polyfill: true diff --git a/core/modules/responsive_image/config/schema/responsive_image.schema.yml b/core/modules/responsive_image/config/schema/responsive_image.schema.yml index f05a8e2..c0b7197 100644 --- a/core/modules/responsive_image/config/schema/responsive_image.schema.yml +++ b/core/modules/responsive_image/config/schema/responsive_image.schema.yml @@ -1,4 +1,11 @@ # Schema for the configuration files of the Responsive Image module. +responsive_image.settings: + type: config_object + label: 'Responsive image settings' + mapping: + use_admin_theme: + type: suppress_polyfill + label: 'Do not use the polyfill' responsive_image.styles.*: type: config_entity diff --git a/core/modules/responsive_image/responsive_image.install b/core/modules/responsive_image/responsive_image.install new file mode 100644 index 0000000..f3179ce --- /dev/null +++ b/core/modules/responsive_image/responsive_image.install @@ -0,0 +1,15 @@ +getEditable('responsive_image.settings') + ->set('suppress_polyfill', FALSE) + ->save(); +} diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 89ac37f..1b10a8c 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -508,7 +508,9 @@ function _responsive_image_image_style_url($style_name, $path) { * Load responsive_image.js whenever ajax is added. */ function responsive_image_library_info_alter(array &$libraries, $module) { - if ($module === 'core' && isset($libraries['drupal.ajax'])) { - $libraries['drupal.ajax']['dependencies'][] = 'responsive_image/ajax'; + if (!\Drupal::config('responsive_image.settings')->get('suppress_polyfill')) { + if ($module === 'core' && isset($libraries['drupal.ajax'])) { + $libraries['drupal.ajax']['dependencies'][] = 'responsive_image/ajax'; + } } } diff --git a/core/modules/responsive_image/src/Element/ResponsiveImage.php b/core/modules/responsive_image/src/Element/ResponsiveImage.php index 2c6f677..65d9230 100644 --- a/core/modules/responsive_image/src/Element/ResponsiveImage.php +++ b/core/modules/responsive_image/src/Element/ResponsiveImage.php @@ -15,12 +15,19 @@ class ResponsiveImage extends RenderElement { * {@inheritdoc} */ public function getInfo() { - return [ - '#theme' => 'responsive_image', - '#attached' => [ - 'library' => ['core/picturefill'], - ], - ]; + if (\Drupal::config('responsive_image.settings')->get('suppress_polyfill')) { + return [ + '#theme' => 'responsive_image', + ]; + } + else { + return [ + '#theme' => 'responsive_image', + '#attached' => [ + 'library' => ['core/picturefill'], + ], + ]; + } } }