Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Created August 20, 2022 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sabrina-zeidan/1768ba63de7129a85dcb6420d89eb0f1 to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/1768ba63de7129a85dcb6420d89eb0f1 to your computer and use it in GitHub Desktop.
Fix WP Rocket Lazyload not working properly on Safari/Chrome 15.4 if loading=lazy is present on the image [WordPress]
//Known issue in Safari 15.4, happens in WPR as well as in other LL plugins
//https://github.com/wp-media/wp-rocket/issues/4961
//Removes loading="lazy" by filtering output buffer in case it wasn't removed in the regular way
add_filter('rocket_buffer', 'sz_wprocket_filter_buffer_native_ll', 10);
function sz_wprocket_filter_buffer_native_ll ($buffer){
$buffer = str_replace('loading="lazy"', '', $buffer);
return $buffer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment