diff options
Diffstat (limited to 'plugins/jetpack/modules/lazy-images/lazy-images.php')
-rw-r--r-- | plugins/jetpack/modules/lazy-images/lazy-images.php | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/plugins/jetpack/modules/lazy-images/lazy-images.php b/plugins/jetpack/modules/lazy-images/lazy-images.php index e77d2e10..befa5ec8 100644 --- a/plugins/jetpack/modules/lazy-images/lazy-images.php +++ b/plugins/jetpack/modules/lazy-images/lazy-images.php @@ -40,6 +40,10 @@ class Jetpack_Lazy_Images { return; } + if ( Jetpack_AMP_Support::is_amp_request() ) { + return; + } + add_action( 'wp_head', array( $this, 'setup_filters' ), 9999 ); // we don't really want to modify anything in <head> since it's mostly all metadata add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) ); @@ -102,11 +106,6 @@ class Jetpack_Lazy_Images { return $content; } - // Don't lazyload for amp-wp content - if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { - return $content; - } - // This is a pretty simple regex, but it works $content = preg_replace_callback( '#<(img)([^>]+?)(>(.*?)</\\1>|[\/]?>)#si', array( __CLASS__, 'process_image' ), $content ); @@ -281,7 +280,8 @@ class Jetpack_Lazy_Images { public function add_nojs_fallback() { ?> <style type="text/css"> - html:not( .jetpack-lazy-images-js-enabled ) .jetpack-lazy-image { + /* If html does not have either class, do not show lazy loaded images. */ + html:not( .jetpack-lazy-images-js-enabled ):not( .js ) .jetpack-lazy-image { display: none; } </style> @@ -339,9 +339,6 @@ class Jetpack_Lazy_Images { } public function enqueue_assets() { - if ( Jetpack_AMP_Support::is_amp_request() ) { - return; - } wp_enqueue_script( 'jetpack-lazy-images', Jetpack::get_file_url_for_environment( |