1

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&h=200">

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!

13
  • I wouldn't add them to the file extension. Just saying. That could break things. How about going for /path/to/image/blahblah.200.200.jpeg? Commented Oct 5, 2010 at 21:21
  • However, on the new host, it won't accept the src attribute with the URL dimension parameter Why not? Who won't accept the attribute? Commented Oct 5, 2010 at 21:21
  • 3
    There is nothing "on the host" that would inhibit an image from showing up with parameters as in your original code, unless a mod_rewrite rule has been set up to do so. Since you would need to set up such a rule to facilitate your solution, you might as well figure out what the source of the original problem is instead. Commented Oct 5, 2010 at 21:21
  • @Matchu: I would have done something along those lines, but I wasn't involved in the site design. Commented Oct 5, 2010 at 21:40
  • @Pekka: When I change DNS settings to the new host, the image src seems to be invalid. Nothing changed between hosts during the transfer so I'm inclined to think there is a setting on the original server which translates from the URL parameters to the filename with the dimensions appended. Commented Oct 5, 2010 at 21:41

2 Answers 2

1

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!

Sign up to request clarification or add additional context in comments.

Comments

0

You have to check jQuery image resize solution which is front-end solution, but it will slow down site appearance. Another solution is php image resize function, which is available for free on the net. http://plugins.jquery.com/project/aeImageResize

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.