axtg86 Posted May 14, 2009 Share Posted May 14, 2009 Hi, I've been reading through the Yahoo speed guidelines, and wanted to do something with the CDN suggestion. Meaning that I want to put my static content (images) on a subdomain. I'm now wondering how I can do this through PHP. I can of course change all my image src locations to <img src="http://cdn.mydomain.com/img/xx" alt=".."/>, but I rather have a PHP script get the images by having something like <img src="cdn.php?file=img.png" alt=".."/> which then loads the image from a server I specified in the cdn.php file (and thus can easily change). It will need to output a header() tag to have the browser recognize the image itself is coming from an external server. I've been playing with a GD library to try to get this done, but I am starting to think I'm making way too much trouble of this. So I figured I would be best of here to check for other opinions . Cheers! Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 14, 2009 Share Posted May 14, 2009 well, if you know where it is you can use file_get_contents() to pull the image's code and then use headers to force it out as an image: header('Content-Type: image/jpeg'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.