Script: modified popup script using thumbnail images

Tags:

All right. At long last, here's a modification of Ye Olde Popup Script as promised. I've had this lying around for months (ok, nearly a year) and just kept forgetting to post it. Hope it helps you.

What does this script do? It's a simple little PHP function. Include() or require() this function in the HTML for your site, and it will allow you to automatically create popups with thumbnail images as the link. (The other version of this script creates text links.) It pops up a clean little window that closes onBlur (meaning, when the user switches focus back to the main window).

Specifically, you feed it three (though, preferably, five) pieces of information:

  • web path to larger image
  • title for image window
  • web path to thumbnail image
  • width of larger image (optional but suggested)
  • height of larger image (optional but suggested)

in a format like this:

<? thumbnail_popup('/misc/big_photo.jpg', 'Silly, silly felines', '/misc/big_photo_thumb.jpg', 240, 350); ?>

Why just the web path and not the full URL? Since PHP allows you to get the server name using $_SERVER['SERVER_NAME'], it seems a little silly to force people to type (and possibly screw up) something that PHP can always get right FOR them.

As always, the web paths and title should be encased in single or double quote marks.

The zip file with all the necessary code can be found here: popup_thumbnail.zip (2k .zip file)

My scripts are what I affectionately term bribeware. If you're looking for changes or mods, a token amount of bribery does wonders for my availability and interest, especially if you don't know me.

domesticat's picture
New version of code added March 15, 2004 - should correct problem with images not loading. Bad cut & paste on my part. I've deleted all old comments on this entry to save confusion.

gfmorris's picture
Spiffy, Amy. Thanks.

Hi, (I hope that I am doing this correctly!!) I was wondering if you knew of a way to have the popup window be centered on the page? Thank you (If I haven't done this correctly, please excuse me and point me in the correct direction)

Just wanted to say thanks for the script.

It look like on onBlur="window.close()" doesn't work with some browsers (safari, for one.) The pop-up window stays open when it loses focus. If the user than clicks open a bigger picture it opens in the same window and is therefore cropped. Can you suggest a way to overcome this? Possible a command to resize the window whenever it is reloaded? Thanks for script and help, Karl

Hi, im trying setuo the codes, but where to need to put the in another page??(html or .php) Ango

thumbnail_popup '/misc/big_photo.jpg', 'Silly, silly felines', '/misc/big_photo_thumb.jpg', 240, 350);
Syndicate content