Jump to content

Load external images through PHP file (<img src="img.php?file=.."/>


axtg86

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/158149-load-external-images-through-php-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.