Created
February 3, 2022 12:14
-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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