tags:

views:

66

answers:

2

I'm in the process of changing hosts and have ran into an issue displaying images. On the current host, images are served up with:

<img id="i1877" src="http://somewebsite.com/images/photo-shoots/XLIscjDrEAdkhzAeDsBrXIedV.jpeg?w=200&amp;h=200"&gt;

However, on the new host, it won't accept the src attribute with the URL dimension parameters. All images are stored on the server in the path format:

/path/to/image/XLIscjDrEAdkhzAeDsBrXIedV.jpeg200x200
/path/to/image/XLIscjDrEAdkhzAeDsBrXIedV.jpeg500x500
/path/to/image/XLIscjDrEAdkhzAeDsBrXIedV.jpeg1000x1000

Is there an Apache2 mod or something that translates from the URL encoded src to the dimensions appended on the end of the filename? I've never seen a system set up like this and just inherited this project, so any help would be much appreciated! Thanks in advance!

A: 

The simplest means of doing this would be to set up a .htaccess file that intercepts all requests to the images in that folder, parses out the image name from the URL ($_SERVER["REQUEST_URI"] is your friend), and then use readfile() to actually output the correct JPEG based on $_REQUEST["w"] and $_REQUEST["h"].

Hope this helps!

mattbasta