Rewrite urls in CSS for CDN/Bucket

Add the following to functions.php
For CSS

add_filter( 'fl_builder_render_css', function( $css, $nodes, $global_settings, $include_global ) {
	$site_url = 'https://example.com';
	$cdn_url  = 'https://123456abcdef.cloudfront.net';

	$css = str_replace( $site_url, $cdn_url, $css );
	return $css;
}, 10, 4 );

For JS

add_filter( 'fl_builder_render_js', function( $js, $nodes, $global_settings, $include_global ) {
	$site_url = 'https://example.com';
	$cdn_url  = 'https://123456abcdef.cloudfront.net';

	$js = str_replace( $site_url, $cdn_url, $js );
	return $js;
}, 10, 4 );
1 Like

What would be the filter to make sure that my Background Slideshow images are coming from my CDN?

Cheers, Richard

you would use the css filter above and replace your urls with the example ones.

1 Like