PDA

View Full Version : Better full-sized image solution (and fairly simple!)


yoyoman
September 8th, 2005, 01:59 AM
I've never liked the fact that when you click on the image for a full-sized version in the shopping cart it opens up a new window using the target parameter of the href which then creates a huge window. Since php has the ability to determine image size, why not use the php function to do just that and then open up the new window (w/javascript) to fit the exact dimensions of the image?

I've already done it and it works great (themodsquad.org/index2.php)! But I had to do an ugly preg_match to get the actual name of the image before finding its dimensions since it was an already-formatted squirrelcart variable (full of html) and otherwise inaccessible to me.

To fix the issue of browser margins what I did was 1) get the image name 2) get the dimensions using php 3) open the new window to those dimensions 4) the specified url is actually always the same super-simple php page with the image name appended via the query string 5) the simple php page has margins set to 0 and shows the image specified in the query string using php to access it (and the query string isn't even visible because the new window has the menu and scroll bars turned off)

:yahoo: