cssmatt Posted April 3, 2006 Share Posted April 3, 2006 I am currently trying to implement a thumbnail generator to my site. I have a few photo galleries which are quite large, so i want to display all these photos as thumbnail, which can be then clicked to show the full size image.The picture path is stored in a mySQL database, and im trying to loop through this DB to retrieve all the photos for the spcific gallery, then run each ful size photo through a thumbnail generator script, to output a small version.I have this done, but the script seems tempramental to say the least! Everytime i run the script, some thumbs are display and some appear as broken links. But the pictures are different everytime, so its not like it cant find the pictures, because refreshing it display different combinations of broken img's.The thumbnail script is straight from php.net [code]<?php// File and new size//$filename = 'http://www.bradmush.co.uk/21/1.jpg';$percent = 0.25;// Content typeheader('Content-type: image/jpeg');// Get new sizeslist($width, $height) = getimagesize($filename);$newwidth = $width * $percent;$newheight = $height * $percent;// Load$thumb = imagecreatetruecolor($newwidth, $newheight);$source = imagecreatefromjpeg($filename);// Resizeimagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);// Outputimagejpeg($thumb);?>[/code]and i am using the follwoing code to loop through the pictures:[code]<?php $sql = "SELECT picture_path FROM loc_pictures WHERE gallery_id = '$_GET[gallery]' LIMIT 25"; $result = mysql_query($sql); echo $num = mysql_num_rows($result) . " pictures found"; $x = 1; while ($row = mysql_fetch_array($result)) { echo "<a href = '$row[picture_path]' rel = 'lightbox'>"; echo "<img src='thumb.php?filename=$row[picture_path]' border = '0' /></a>"; echo " "; $x ++; }?>[/code]The picture path is saved in the format "../gallery/1/1.jpg" and ive also tried changing this to an absolute path, which doesn work either!!Plus, to add insult to injury sometimes i get a 403 forbidden error, which im not sure if this is related, but it isnt permanent, and seems to be remidied by refreshing my FTP?!Any help would be grand!! Quote Link to comment Share on other sites More sharing options...
shocker-z Posted April 3, 2006 Share Posted April 3, 2006 What about if you right click on the image? does it show the right image and does the link follow to the correct location? if so then all i can think is that the computer is overloading and skipping the odd image as too much data transfer have you tryed limiting it to less images and see if it still happens? Quote Link to comment Share on other sites More sharing options...
cssmatt Posted April 3, 2006 Author Share Posted April 3, 2006 Yeah if i "Show Picture" then it displays it fine. Changing the limit does help, because the broken images didnt appear in the first 10 photos. Its only over that amount that problems occur.Is there no other work around than displaying in blocks of 10? Because the full size images are only 400 x 400 photos?! And there are only 24 or so in each gallery?? 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.