diff options
Diffstat (limited to 'plugins/jetpack/modules/theme-tools/compat/twentysixteen.php')
-rw-r--r-- | plugins/jetpack/modules/theme-tools/compat/twentysixteen.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php index 4f96c7c4..7e106037 100644 --- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php +++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php @@ -49,3 +49,19 @@ function twentysixteen_remove_share() { } } add_action( 'loop_start', 'twentysixteen_remove_share' ); + +function twentysixteen_jetpack_lazy_images_compat() { + if ( ! function_exists( 'wp_add_inline_script' ) ) { + return; + } + + // Since TwentySixteen outdents when window is resized, let's trigger a window resize + // every time we lazy load an image on the TwentySixteen theme. + wp_add_inline_script( + 'jetpack-lazy-images', + "jQuery( document.body ).on( 'jetpack-lazy-loaded-image', function () { jQuery( window ).trigger( 'resize' ); } );" + ); +} + +// Priority needs to be 11 here so that we have already enqueued jetpack-lazy-images. +add_action( 'wp_enqueue_scripts', 'twentysixteen_jetpack_lazy_images_compat', 11 ); |