Skip to content

Instantly share code, notes, and snippets.

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/62d0f324fa7c574baf1828d162bfb77a to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/62d0f324fa7c574baf1828d162bfb77a to your computer and use it in GitHub Desktop.
Serve WEBP format from JetPack CDN using WP Rocket buffer output [WordPress]
//For testing purposes
if (!is_user_logged_in() ) {
function sz_wprocket_filter_buffer($buffer)
{
$jetpack_cdn = 'https://i1.wp.com/';
$buffer = preg_replace('/((http|https)\:\/\/)(([^\"|^\)|^\']*?)(?:.jpg|.jpeg|.png))/im', $jetpack_cdn . '${3}', $buffer);
return $buffer;
}
add_filter('rocket_buffer', 'sz_wprocket_filter_buffer', 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment