diff --git a/core/modules/responsive_image/responsive_image.js b/core/modules/responsive_image/responsive_image.js new file mode 100644 index 0000000..a2330a9 --- /dev/null +++ b/core/modules/responsive_image/responsive_image.js @@ -0,0 +1,16 @@ +(function (Drupal) { + + "use strict"; + + /** + * Call picturefill so newly added responsive images are processed. + */ + Drupal.behaviors.responsive_images = { + attach: function () { + if (window.picturefill) { + window.picturefill(); + } + } + }; + +})(Drupal); diff --git a/core/modules/responsive_image/responsive_image.libraries.yml b/core/modules/responsive_image/responsive_image.libraries.yml new file mode 100644 index 0000000..91f0dba --- /dev/null +++ b/core/modules/responsive_image/responsive_image.libraries.yml @@ -0,0 +1,4 @@ +drupal.responsive_image: + version: VERSION + js: + responsive_image.js: {} diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index f7e2192..0603435 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -480,3 +480,14 @@ function _responsive_image_image_style_url($style_name, $path) { } return file_create_url($path); } + +/** + * Implements hook_library_info_alter(). + * + * 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'][] = array('responsive_image/responsive_image'); + } +}