2 //////////////////////////////////////////////////////////////
3 /// phpThumb() by James Heinrich <info@silisoftware.com> //
4 // available at http://phpthumb.sourceforge.net ///
5 //////////////////////////////////////////////////////////////
7 // See: phpthumb.readme.txt for usage instructions //
9 //////////////////////////////////////////////////////////////
11 // phpThumb.demo.showpic.php //
12 // James Heinrich <info@silisoftware.com> //
15 // This code is useful for popup pictures (e.g. thumbnails //
16 // you want to show larger, such as a larger version of a //
17 // product photo for example) but you don't know the image //
18 // dimensions before popping up. This script displays the //
19 // image with no window border, and resizes the window to //
20 // the size it needs to be (usually better to spawn it //
21 // large (600x400 for example) and let it auto-resize it //
22 // smaller), and if the image is larger than 90% of the //
23 // current screen area the window respawns itself with //
27 // window.open('showpic.php?src=big.jpg&title=Big+picture', //
28 // 'popupwindowname', //
29 // 'width=600,height=400,menubar=no,toolbar=no') //
31 // See demo linked from http://phpthumb.sourceforge.net ///
32 //////////////////////////////////////////////////////////////
34 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
37 <title><?php echo @$_GET['title']; ?></title>
39 <script language="Javascript">
41 // http://www.xs4all.nl/~ppk/js/winprop.html
42 function CrossBrowserResizeInnerWindowTo(newWidth, newHeight) {
43 if (self.innerWidth) {
44 frameWidth = self.innerWidth;
45 frameHeight = self.innerHeight;
46 } else if (document.documentElement && document.documentElement.clientWidth) {
47 frameWidth = document.documentElement.clientWidth;
48 frameHeight = document.documentElement.clientHeight;
49 } else if (document.body) {
50 frameWidth = document.body.clientWidth;
51 frameHeight = document.body.clientHeight;
55 if (document.layers) {
56 newWidth -= (parent.outerWidth - parent.innerWidth);
57 newHeight -= (parent.outerHeight - parent.innerHeight);
60 //parent.window.resizeTo(newWidth, newHeight);
62 // fixed code: James Heinrich, 20 Feb 2004
63 parent.window.resizeBy(newWidth - frameWidth, newHeight - frameHeight);
70 <body style="margin: 0px;">
73 if (get_magic_quotes_gpc()) {
74 $_GET['src'] = stripslashes($_GET['src']);
77 if ($imgdata = @getimagesize($_GET['src'])) {
79 // this would be an excellent place to put some caching stuff to avoid re-scanning every picture every time
81 // check for maximum dimensions to allow no-scrollbar window
82 echo '<script language="Javascript">'."\n";
83 echo 'if (((screen.width * 1.1) > '.$imgdata[0].') || ((screen.height * 1.1) > '.$imgdata[1].')) {'."\n";
84 // screen is large enough to fit whole picture on screen with 10% margin
85 echo 'document.writeln(\'<img src="'.$_GET['src'].'" border="0">\');';
86 echo 'CrossBrowserResizeInnerWindowTo('.$imgdata[0].', '.$imgdata[1].');'."\n";
88 // image is too large for screen: add scrollbars by putting the image inside an IFRAME
89 echo 'document.writeln(\'<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'">Your browser does not support the IFRAME tag. Please use one that does (IE, Firefox, etc).<br><img src="'.$_GET['src'].'"></iframe>\');';
95 // cannot determine correct window size, or correct size too large: add scrollbars by putting the image inside an IFRAME
96 echo '<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'"></iframe>';