perik Posted April 8, 2010 Share Posted April 8, 2010 Hi! Im using an random image script which works fine but that I want to edit a bit. I have edited it a bit so when you click on a image you get a fullsize in a popup. The problem is that the image in the popup is also random and not always a bigger copy of the thumbnail, the smaller one you clicked on as I want: see it live here, and I think you will understand what I want to achieve: see it here the code Im using is: randim.php <?php /* The default folder with images */ $settings['img_folder'] = 'bildermini/'; /* File types (extensions) to display */ $settings['img_ext'] = array('.jpg','.gif','.png'); /* How to display the images? 0 = print just the image path (for includes), like: images/test.jpg 1 = redirect to the image, when using: <img src="randim.php" /> */ $settings['display_type'] = 1; /* Allow on-the-fly settings override? 0 = NO, 1 = YES */ $settings['allow_otf'] = 1; /******************************************************************************* /* Override type? */ if ($settings['allow_otf'] && isset($_GET['type'])) { $type = intval($_GET['type']); } else { $type = $settings['display_type']; } /* Override images folder? */ if ($settings['allow_otf'] && isset($_GET['folder'])) { $folder = htmlspecialchars(trim($_GET['folder'])); if (!is_dir($folder)) { $folder = $settings['img_folder']; } } else { $folder = $settings['img_folder']; } /* Make sure images fodler ends with an '/' */ if (substr($folder,-1) != '/') { $folder.='/'; } /* Get a list of all the image files */ $flist = array(); foreach($settings['img_ext'] as $ext) { $tmp = glob($folder.'*'.$ext); if (is_array($tmp)) { $flist = array_merge($flist,$tmp); } } /* If we have any images choose a random one, otherwise select the "noimg.gif" image */ if (count($flist)) { $src = $flist[array_rand($flist)]; } else { $src = 'noimg.gif'; } /* Output the image according to the selected type */ if ($type) { header('Location:'.$src); exit(); } else { echo $src; } ?> and for calling 3 random images: test.php <ol> click for bigger image: <li> <a class="fancy" rel="fancy" href="<?php $_GET['type']=0; $_GET['folder']='bilderstora'; include 'randim.php'; ?>"><img border='0' src="<?php $_GET['type']=0; $_GET['folder']='bildermini'; include 'randim.php'; ?>"></a></p> </li> <li> <a class="fancy" rel="fancy" href="<?php $_GET['type']=0; $_GET['folder']='bilderstora'; include 'randim.php'; ?>"><img border='0' src="<?php $_GET['type']=0; $_GET['folder']='bildermini'; include 'randim.php'; ?>"></a></p> </li> <li> <a class="fancy" rel="fancy" href="<?php $_GET['type']=0; $_GET['folder']='bilderstora'; include 'randim.php'; ?>"><img border='0' src="<?php $_GET['type']=0; $_GET['folder']='bildermini'; include 'randim.php'; ?>"></a></p> </li> </ol> how do I edit the code so I get the same image on the link as it is on the thumbnail? the images are stored in: bildermini/ (thumbnails) bilderstora/ (big image) thanks for your help! Perik Quote Link to comment Share on other sites More sharing options...
Matthias_ Posted April 12, 2010 Share Posted April 12, 2010 Hmm, maybe use $_POST to send the string in the image? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.