Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Smush Pro] - Fix thumbnails of lightgallery not loading when enabled lazyload
<?php
/**
* Plugin Name: [Smush Pro] - Fix thumbnails of lightgallery not loading when enabled lazyload
* Description: [Smush Pro] - Fix thumbnails of lightgallery not loading when enabled lazyload - 1153334378527255
* Author: Thobk @ WPMUDEV
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'wp_footer', function () {
if( defined('WP_SMUSH_VERSION') && class_exists( 'Smush\WP_Smush' ) ){
// return if disabled lazyload
if( ! Smush\Core\Settings::get_instance()->get('lazy_load') ) return;
?>
<script>
jQuery( document ).on( 'doResponsiveLightbox', function ( event ) {
var item = 'lightbox-gallery';
jQuery( 'a[rel^="' + item + '"], a[data-rel^="' + item + '"]' ).each(function(){
lazySizes.loader.unveil(jQuery(this).children('img')[0]);
});
});
</script>
<?php
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.