Jump to content

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)

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.