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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.