|
|
|
|
![]() ![]() |
Sep 18 2006, 01:45 AM
Post
#1
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 4,076 Joined: 24-July 05 From: Linix, DOS and Windows…the good, the bad and the ugly Member No.: 9,787 ![]() |
As reported in another posting, there is an Image Gallery named Hoverbox from the Sonspring site which is a pretty cool display method using CSS to have Thumbnail pictures double their size by hovering over them.
I liked the css included in the original Tutorial as found on the Sonspring site, but I knew there was more than one use for the Hoverbox and took it upon myself to explore the use of the Hoverbox on a site I webmaster.
CODE // Hoverbox Image Gallery - adapted // // Original Hoverbox code by Nathan Smith // http://sonspring.com/journal/hoverbox-image-gallery // // PHP script adaptation by Jim Haslip jlhaslip@yahoo.ca // // A main feature in the original Hoverbox was a method for the thumbnail // Images to grow to double the thumbnail size when hovered over. // The Hoverbox swap of Images is entirely CSS-based. No javascript was injured in // the making of this display. // // Added in this script are : // - an on-click event to display the Images full size // - added the php scripting to load the contents from a directory // - added a max number of images to be displayed // - added a random feature for selecting the Images to be displayed // // There could be several versions adapted from this script. ie: remove the full size // on-click feature, change the maximum number to display, remove the randomness. // I will eventually have each of these versions available, but at present, // you will have to Mod the script yourself. // // // <?php echo '<ul class="hoverbox">'; // // set some variables used in the script // $max_num = 15; // maximum images displayed in the Hoverbox $j=0; // a counter variable $narray = array(); // declare an array containing the file-names of the images // // set directory paths here. // There are Bandwidth issues with loading the 'full-size' pictures for use as thumbs // and mid-size, however, there is a time-delay issue on-click when the full-size // picture must then be downloaded. Your call on that one. The Demo uses three Folders. // To minimize the bandwidth usage, use only one directory of optimized pictures, // but be sure to alter the paths accordingly. // All occurences of a picture MUST have the SAME NAME whether in one or three directories. // The filenames don't appear to be case-sensitive. ( PIC001 = pic001 = PiC001 = pIc001 ) // $dir = "images/"; // name of the folder where the Thumbnail images are stored $mid_dir = "mid_images/"; // name of the folder where the Mid-sized images are stored $full_dir = "full_images/"; // name of the folder where the Full-sized images are stored // // check to confirm the directories exist and can be opened // if (is_dir($dir) && (is_dir($mid_dir)) && (is_dir($full_dir)) ) { $dh= @opendir($dir) or die("Unable to open $path please notify the administrator. Thank you."); // // loop while you read the entire directory listing selecting only files which // 1. are not the (.) or (..) directories // 2. are jpeg ( or as specified in the file type below ) // 3. exist in both the mid-size and full-size directories named in the path variables // while (($file = readdir($dh)) !== false) { // // ignore the directory entries and only select the .jpg file extension files // alter the '.jpg' to suit your format // if (($file != '.') && ($file != '..') && (stristr($file,'.jpg'))) { // // confirm the file exists in both the mid and full directories // if ((file_exists($mid_dir . $file)) && (file_exists($full_dir . $file))) { // // add them to an array if all is good so far // $narray[]=$file; // // increase counter when a file is added to the array // $n++; } } } // // reset the max_num if not enough pictures meet the criteria // if ($n < $max_num) { $max_num = $n; } // // randomize the array for presentation // shuffle( $narray); // // echo the correct html as per the Hoverbox Tutorial found at // http://www.sonspring.com // while ( $j <= $max_num-1) { echo "\t" . '<li><a href="' . $full_dir . $narray[$j] . '" alt="full-size"> <img src="' . $dir . $narray[$j] . '" alt="' . $dir . $narray[$j] . '" > <img src="' . $mid_dir . $narray[$j] . '" alt="mid-size" class="preview" /></a></li> ' . "\n\r\t"; $j++; } } // // report an error on the directory confirmation // else { echo 'There is a problem with the directories. Please Notify the Administrator. Thank You.';} closedir($dh); echo '</ul>'; ?> View a Sample Page Here. |
|
|
|
Sep 19 2006, 11:17 AM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 4,076 Joined: 24-July 05 From: Linix, DOS and Windows…the good, the bad and the ugly Member No.: 9,787 ![]() |
I created this Tutorial several days ago, but the codebox information was getting a weird control character inside it which wouldn't let the contents display correctly.
It may have been something to do with the editting and transfer of the text to/from a mac machine and then to the Linux server, although I have done it that way before, so go figure? Enjoy. |
|
|
|
Sep 19 2006, 02:36 PM
Post
#3
|
|
|
Legend Killer ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 678 Joined: 15-April 05 From: Singapore Member No.: 5,697 |
There is something strange about the image hover stuff... It seems that the image hovering isnt welly shown, with the other image thumbnail blocking the parts of the hovering image, it really spoils the image view of it... Could that part be fixed?
|
|
|
|
Sep 19 2006, 05:49 PM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 822 Joined: 6-March 05 Member No.: 4,202 |
Thanks. The Hoverbox Image Gallery is very interesting itself but the changes you´ve made arepretty good and improve the results. I want to make use of this, maybe I´ll do a little website with a few images to check it out.
|
|
|
|
Sep 19 2006, 08:34 PM
Post
#5
|
|
|
Trap Grand Marshal Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 1,137 Joined: 19-May 05 From: Mexico Member No.: 7,234 |
Great tutorial! I was going to need something like this in the next few weeks, I had already thought of how I was going to do it, even though it seems like my work is done, Im still going to do it bymyself and in the end I will compare and see if its as goos as the hoverbox. Thanks for sharing
|
|
|
|
Sep 19 2006, 11:44 PM
Post
#6
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 4,076 Joined: 24-July 05 From: Linix, DOS and Windows…the good, the bad and the ugly Member No.: 9,787 ![]() |
HYpe,
Either I don't understand the problem you are having, or I can't duplicate it. I have checked this script with three browsers and two versions of php and it all works well for me. Only thing that I can't check is the function in Internet Explorer 7 because I do not have that Browser installed. What browser are you using? Please post it here or pm me and I will see what can be done. Thanks. Sprnknwn and Flakes, Thanks for your comments and good luck with it. |
|
|
|
Sep 20 2006, 12:12 AM
Post
#7
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 503 Joined: 18-August 06 From: My Computer, Mumbai, Maharashtra, India. Member No.: 28,463 ![]() |
I needed something like this and found some rather odd ones on CSSPlay, anyways, very nice gallery and I will surely use it on my website soon.
Thanks Jhaslip. |
|
|
|
Sep 20 2006, 03:45 AM
Post
#8
|
|
|
Legend Killer ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 678 Joined: 15-April 05 From: Singapore Member No.: 5,697 |
I'm using IE7.0, perhaps that's the problem... I'll have a little try on my FireFix browser and see if there's any prob...
Here's a screenshot of the problem I encounter, the hover doesnt really stand out from other pictures, and get cover by the thumbnail of others... http://img.photobucket.com/albums/v507/hyp...er/hoverpic.jpg This post has been edited by hype: Sep 20 2006, 03:46 AM |
|
|
|