Jump to content

Image display/load script?


acctman

Recommended Posts

I'd like to rewrite the way images are shown on my site, with a php script so if image http://domain.com/2005/02/39/39-3001.jpg is loading the url would show http://domain1.com/display.php?3001 and display.php would not allow direct access from other domains the referring URL would have to be coming from domain1.com or domain2.com. The html img src code has to be able to read "http://domain1.com/display.php?3001"  and display an image

 

thanks

Link to comment
Share on other sites

You want to use .htaccess and url re-writing.

 

I'm no expert, so google it or I'm sure someone will help out soon enough.

 

Edit: found it

RewriteEngine on
rewriterule (.*)\.jpg$ /display.php?a=$1.jpg [R,L]

 

Should work I think. Then in display.php just make sure the referrer is allowed (in_array() should do the job nicely) and display the image.

Link to comment
Share on other sites

The following is if you want to go down the PHP path:

 

How is it supposed to map 3001 to 2005/02/39/39-3001.jpg with just "?3001"?

 

It would have to know where the image was, but if the script knew that, it could just do something like:

 

[psuedo code]

 

if(referer == from this site) {
    //get image id from the ?number (process $_SERVER['QUERY_STRING'])
     if(image_exists) {
          readfile(path_to_image);
         exit;
     }
}

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.