On our 4.1.x here's how we did our thumbnail and product images.
Open include/func/func.files.php
FIND:
Code:
if (!strncmp($xcart_dir, $image_path, strlen($xcart_dir)) && @file_exists($image_path)) {
BEFORE add:
Code:
// WCM - CDN Images
if (($type == 'T' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')
return str_replace('/home/path/to/your/images/','http://cdn.example.com/',$image_path);
// / WCM - CDN Images