The sed solution:
Use sed on all you html files. You can loop through all files with PHP (or a script function). glob is a great function for this.
<?php
// this sed assumes you have
// <img src="imgs/example.png" />
// and want to change it to
// <img src="http://www.noCookies.com/imgs/example.png" />
// Loop through each .html file in current directory and create an .html2
// If satisfied w results can finalize .html2 files
// I use .html2 so you don't overwrite your original files
foreach (glob("*.html") as $file)
{
// You have to escape double quotes
$lookFor = 'src=\"imgs';
$replaceWith = 'src=\"http://www.noCookies.com/imgs';
// create the sed command:
// _g is to do a global search
$shellCommand = "sed s_{$lookFor}_{$replaceWith}_g {$file}";
// create a NEW file and open it
$fp = fopen("{$file}2", "w");
// preform sed and write it to the new file
fwrite($fp, shell_exec($shellCommand));
fclose($fp);
}
?>
Edit - original answer follows:
Another option option, which is probably just as slow or slower than the original is mod rewrite
If you run Apache, and all the images are in a separate folders (even if they're not, but then it's more work), you could use mod_rewrite... something like this...? I'm a little rusty oon mod_rewrite, but you want to take the relative path, and switch it with an absolute path:
RewriteEngine on
RewriteRule ^media/images/(.*) http://noCookies.com/media/images/$1 [L]
I think it's definitely the way the go though. Then you can change the old img sources slowly over time. Or just keep the old ones and add in the correct img src for any new images you add.
Here is the mod_rewrite documenation, which is a little opaque... Some of the tutorials on preventing image hotlinking could also be helpful
I just remembered, this is a good mod_rewrite tips and tricks page