Jump to content

Dynamic Image Popup Window


stevesimo

Recommended Posts

Hi, I have a page which displays details of products including images.  I want to add a link to display an large version of the image in a popup window.  Can this be done with PHP or do I need to use Javascript? Can anyone offer any advice on what is the best way to achieve this?

 

Thanks, Steve (Blackpool)

Link to comment
https://forums.phpfreaks.com/topic/51384-dynamic-image-popup-window/
Share on other sites

You have to use javascript to open the pop up window.  You would use php to dynamically generate the link that actually opens the window. 

 

 

 

You can also use php gd functions to get the width and height of the image and pass those parameters into your javascript function so it will open the right sized window for the picture.  Once you've used these functions to analyse the dimensions, just drop them in where I have image_x image_y.  I can't remember if I have every apostrophe here correct but you can play around with it.  Of course you will have to put the dynamically generated variables into the <a> tags with php.

 

<a href="#" onclick="openWindow('path_to_image','image_x','image_y')"><img src="path_to_image"/></a>

 

And then just make a javascript file with the openWindow function in it and do a little searching on how to open a window in javascript with the various parameters.

 

 

Thanks for the help, I have just had a quick look on the internet and found a decent Javascript example at the following site: http://www.pageresource.com/jscript/jwinopen.htm

 

Will attempt this tomorrow when I get to work.  Yet again thanks for your help.

 

Steve (Blackpool)

Archived

This topic is now archived and is closed to further replies.

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