This can now also be accomplished via the beta script, which contains an array with allowed hostnames. But still good info to know.
Love the TimThumb script for auto-generating thumbnails in WordPress, but feeling hemmed in by the requirement the image be hosted on your domain? If you use another domain for your image storage–to parallelize domains as recommended by Google’s Page Speed–you can, with a simple edit to the script.
Note: This only works for a using single, different domain from your blog, parked atop your current blog domain.
- So first, get your domain set up and parked.
- Then, change the upload settings in WordPress (under “Settings > Miscellaneous”) . Leave the “Store uploads in this folder” setting alone. But for the “Full URL Path to files, enter ” http://mydomain.com/wp-content/uploads”1
- Then, you dig into the script to make your adjustment. Find this line:
$host = $_SERVER["HTTP_HOST"];
And replace with this line:
$host = "mydomain.com";
Now, all your uploaded images will be stored in exactly the same folder as before physically, but use the parked domain’s url to display, which makes your site load faster since browsers only fetch a specific number of resources at a time, grouped by source domain. And your generated thumbnails will work without incident!
While I generally don’t advocate editing a core script file to get the desired behavior, it’s a small edit for a reasonably good payout of faster page load speed. Just make sure you note the changes someplace where you can find them so you’re not scratching your head as to why your thumbnails quit working when you upgrade the script next time around.
- Without the quotes in the WordPress settings, and of course, replacing “mydomain.com” with your own domain. Duh. [↩]

{ 1 comment… read it below or add one }
Note- Using the beta script from the Yellow box, you’ll need to create a folder called “temp” in the same directory as your TimThumb script, and give it permissions 777 or 755, as appropriate for writable on your server.