Thank you Frederick.
I fixed this by replacing urls via PHP str_replace function.
Can I use this plugin's functions to sort this problem out? If so, what functions should I use? I was playing around with creating new W3_Cdn object but without success.