summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-09-26 11:47:40 (GMT)
committerAlex Pott2015-09-26 11:47:40 (GMT)
commit3473bd5d3aabf654b3a9585a8ba426ad1b0cd844 (patch)
tree0bac771300ff16a2a569248423a0fd42902846cf
parentcec8f5eb30eeffbfc6a574c89d1602dd78c722db (diff)
Issue #1836860 by attiks, durgesh_singh, Jelle_S, nod_, vks7056, Wim Leers: Picture doesn't work with AJAX callback
-rw-r--r--core/modules/responsive_image/js/responsive_image.ajax.js16
-rw-r--r--core/modules/responsive_image/responsive_image.libraries.yml4
-rw-r--r--core/modules/responsive_image/responsive_image.module11
3 files changed, 31 insertions, 0 deletions
diff --git a/core/modules/responsive_image/js/responsive_image.ajax.js b/core/modules/responsive_image/js/responsive_image.ajax.js
new file mode 100644
index 0000000..2c12b71
--- /dev/null
+++ b/core/modules/responsive_image/js/responsive_image.ajax.js
@@ -0,0 +1,16 @@
+(function (Drupal) {
+
+ "use strict";
+
+ /**
+ * Call picturefill so newly added responsive images are processed.
+ */
+ Drupal.behaviors.responsiveImageAJAX = {
+ 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..d7f0e2e
--- /dev/null
+++ b/core/modules/responsive_image/responsive_image.libraries.yml
@@ -0,0 +1,4 @@
+ajax:
+ version: VERSION
+ js:
+ js/responsive_image.ajax.js: {}
diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module
index ec4dbe1..9c818ca 100644
--- a/core/modules/responsive_image/responsive_image.module
+++ b/core/modules/responsive_image/responsive_image.module
@@ -475,3 +475,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'][] = 'responsive_image/ajax';
+ }
+}