Skip to content

Commit b35da6a

Browse files
authored
Merge pull request #702 from cloudinary/fix/cldbind
Fix/cldbind
2 parents 9efaffa + c096a7c commit b35da6a

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

js/inline-loader.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'e7aff784a3c9f5bd00c754dd8d63395d');
1+
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'e2518755df24a06ffeada9103eb32f0b');

js/inline-loader.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

php/delivery/class-lazy-load.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ public function add_features( $tag_element ) {
203203
}
204204
// Since we're appending to the onload, check it isn't already in, as it may run twice i.e full page caching.
205205
if ( false === strpos( $tag_element['atts']['onload'], 'CLDBind' ) ) {
206-
$tag_element['atts']['onload'] .= ';window.CLDBind?CLDBind(this):null;';
206+
$tag_element['atts']['data-cloudinary'] = 'lazy';
207+
$tag_element['atts']['onload'] .= ';window.CLDBind?CLDBind(this):null;';
207208
}
208209
}
209210

src/js/inline-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ window.CLDBind = ( image )=>{
244244
};
245245
// Fallback.
246246
window.addEventListener( 'load', () => {
247-
[...document.querySelectorAll('img[data-public-id][onload]')].forEach( ( image )=>{
247+
[...document.querySelectorAll('img[data-cloudinary="lazy"]')].forEach( ( image )=>{
248248
CLDBind( image );
249249
})
250250
} );

0 commit comments

Comments
 (0)