Change Image URL to a CDN
Running NGINX, Wordpress 4.75 after upgrading from a way older version of Wordpress, our images are being served locally and I would like to change that to our CDN.
In the past images that were uploaded to the blog were uploaded directly to our CDN using a plugin ( I think Offload S3 Lite ).
My goal is that I want post images, thumbnail etc URL to be served from our CDN and not local.
For example I have: https://test.com/blog/wp-content/uploads/2016/07/Wedding1-370x215.jpg
Needs to point to: https://cdn.test.com/blog/wp-content/uploads/2016/07/Wedding1-370x215.jpg
Before the wordpress site (was not updated for a while) was uploading images directly to the CDN (AWS S3 -> Cloudfront) now that we upgraded to 4.75 the images that get served are pointing to local url instead of our CDN url.
images are served through the functions like: the_post_thumbnail()
Which I believe uses wp_get_attachment_image under the hood. If I can included a function in my functions.php to rewrite image urls that could work too.
So how can I get the image urls to point to our CDN and instead of local url?
Thanks for your help!