Add to Google

Image Gallery Tutorial Using Hoverbox - A php solution to coding the Hoverbox Image Gallery

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #14) by matak on Jul 26 2007, 09:53 AM. (Line Breaks Removed)
If you want to run IE7, and IE6 on machine to test your sites you can use Standalone Edition. Maybe you can google for even better link for DL.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Tutorials

Image Gallery Tutorial Using Hoverbox - A php solution to coding the Hoverbox Image Gallery

jlhaslip
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.
  • One thing that wasn't right was having to hardcode the image tags, so the first version I wrote used php to fill the Hoverbox by reading the Image filenames from the Image folder and inserting them into the html.
  • Another was the use of the anchor (<a>) tag to trick Internet Explorer into activating the on-hover event, so I included the filename as the target of the anchor tag so that the on-click event actually does something. It opens a window and displays the full sized picture in your browser.
  • The website I wanted to use the Image Gallery on is for a Minor Hockey program and I also wanted a 'randomization' of the pictures so that each time you viewed the page a different selection of pictures was displayed. This avoids the possibility of suspicious selection methods (Why isn't little Johnny's picture on the site?)
  • and lastly, I wanted this code to be flexible in terms of the number of pictures displayed on the page, so I have a 'maximum number' variable which displays, well, a maximum number of pictures. This raised the possibilty of there not being enough Images, so a check is made to display the lesser of the max_num or actual_num of pictures.
I leave it to you to visit the Sonspring site to check out the actual Hoverbox code. In this Tutorial, I will focus on the php coding for the Hoverbox which my script enhances as per the list of features above.

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.

 

 

 


Reply

jlhaslip
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.

Reply

hype
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?

Reply

Sprnknwn
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.

Reply

FLaKes
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

Reply

jlhaslip
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.

Reply

sylenzednuke
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. smile.gif

Reply

hype
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

Reply

DarkPsycho
yea i just tried it on my IE7 and it is exactly like his screenie.
although i think IE7 is still in its beta stages so it might be fixed when the final comes out (although knowing past IE's it might not be)

Reply

jlhaslip
Thanks for the screenshot, HYpe and the confirmation, DarkPsycho.

I will definately look into this problem. It is probably something to do with an IE6 hack and IE7 that doesn't need the hack. Usually, this can be solved by using a conditional statement for IE and different CSS file for those browsers which need it.

Stay tuned for the modifications to come.

*by the way*, does the 'on-click' okay work in IE7?

Reply

Latest Entries

matak
If you want to run IE7, and IE6 on machine to test your sites you can use Standalone Edition. Maybe you can google for even better link for DL.

Reply

jlhaslip
Here is a link to a gallery of paintings which a local student has on display at an Art Gallery.

I built a web page for him using the Hoverbox Gallery php script above.

http://www.taryngillies.com

Any and all comments are appreciated.

Reply

hype
Ok, thanks... Is it possible to create a catergory feature where we can group those pictures into different catergory and then perhaps the catergory shows some of the thumbnail of the pictures inside the catergory, that would be perfect... I'm looking foward to it, hope it will work like wonders lol... smile.gif

btw, the actual hoverbox image gallery from the sonspring site did not have a problem with that css thing and it works perfectly with IE7.0...

http://host.sonspring.com/hoverbox/

Reply

jlhaslip
Hype,
Don't worry about anything. I am sure that IE knows all about the problems with IE's non-standard rendering of CSS. They are in the middle of fixing it, so relax.
The only fix is for me to have some time to research the CSS and I simply do not have the time until probably this weekend.
I promise to get to it and advise you when it is available for testing and you can do the beta test for me.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. how to display image stored in folder using javascript - 19.00 hr back. (1)
  2. dynamic gallery tutorial - 21.17 hr back. (1)
  3. scroller demo by nathan smith. read the tutorial - 24.15 hr back. (1)
  4. css image viewer - 27.24 hr back. (1)
  5. random image gallery css php tutorial - 35.68 hr back. (1)
  6. php image gallery tutorial - 36.17 hr back. (1)
  7. "simple image gallery tutorial" - 44.93 hr back. (3)
  8. hoverbox tutorial - 45.68 hr back. (1)
  9. html image gallery for my website - 66.01 hr back. (1)
  10. tutorial image over html gallery - 67.75 hr back. (1)
  11. " simple image gallery tutorial " - 73.79 hr back. (1)
  12. swap image js gallery - 81.37 hr back. (1)
  13. javascript hoverbox - 90.74 hr back. (1)
  14. script for swapping images for a times gallery - 88.03 hr back. (2)
Similar Topics

Keywords : image, gallery, hoverbox, php, solution, coding, hoverbox, image, gallery

  1. Nice Clean Php Layout Coding.
    Learn a nice neat way to code your layouts with php (7)
  2. Background Image Swap Script
    Change a Background Image based on clock time (15)
    Background Image Changer Script To swap the background image from your CSS file according to the
    Server Clock Time. 1.) In your CSS file, add the following rule: CODE body {
        background: url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the
    folder, place three images named morning.png, day.png, night.png. 4.) Also, in the same folder,
    create an index.php file and copy/paste the following script. CODE <?php $hour =
    date('H'); if ($hour < 12 ) {     $image =
    "morning.png"; } ....
  3. Image Rotator Script (another One)
    easy to implement (0)
    In case you haven't noticed, I have a different Avatar display on the Forum each time the page
    is refreshed. /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
    /> For those of you who might want the script to do that, here is the one I am using: HTML
    $filesp = glob('*.png'); if(empty($filesp)){ echo
    'no images found...die br >'; die(); } else{ foreach ($filesp as
    $file) { $img_array[] = trim($file); }....
  4. Math Captcha Image Validation
    (1)
    This tutorial will show you how to make a basic math CAPTCHA validtion form. This requires that you
    have the GD library for PHP installed to work. This tutorial requires 2 files, login.php and
    action.php. The first step is to create a sub-folder to store the temporary images, for the
    purposes of this tutorial,this folder should be called images. Now upload a image in there called
    verify.php and chmod just that image(not the folder) to 777 so that image can change as our
    functions generate new images. Ok, after you've done that, we can get to the code: in login.p....
  5. A Simple Php Captcha - Image Validation
    (21)
    OK, I recently had the need to create a PHP CAPTCHA system for a friend, and I am sharing this as a
    tutorial with the good people here at Trap17. I am sure you have all seen a CAPTCHA before (although
    you may not have known what it was called). They are the little codes you often have to enter when
    you register with a site, to make sure you are a person and not an automated script. Some common
    examples look something like this: My system doesn't really do anything as fancy, but I
    think that it is slightly more readable that some of those that get generated. Every....
  6. How To Make Image To Highlight When It`s Mouseovered
    (8)
    Place this code between and tags. CODE <script
    language="JavaScript1.2"> <!-- function makevisible(cur,which){
    strength=(which==0)? 1 : 0.2 if (cur.style.MozOpacity)
    cur.style.MozOpacity=strength else if (cur.filters) cur.filters.alpha.opacity=strength*100 }
    // --> </SCRIPT> Place the following code within all of the image tags you'd
    like the effect to be applied. CODE
    style="filter:alpha(opacity=20);-moz-opacity:0.2"
    onMouseover="makevisible(....
  7. Uploading Images To The Trap17 Gallery
    A How To, on uploading images to the trap17 gallery (4)
    Well, seeing as how BuffaloHelp or OpaQue has told us to upload our images to the trap17 gallery
    instead of our own, i figure that i could help out those who dont know how to do it because it
    isn't all that easy for the noobs. Uploading Images To The Trap17 Gallery Step 1:..
    Obviously You need a picture so get one of those Step 2:.. Go to "My Controlls" Step 3:.. Once
    you get there, on the left hand side look for "Invision Gallery" Step 4:.. Click On "Your Albums"
    Step 5:.. Now you need to create an album so click on "Create My First Album" S....
  8. Image Shack Mod
    For Invision Power Board (2)
    Image Shack Mod For Invision Power Board ''These instructions will help you to install
    'ImageShack on your Site' into the reply, quick-reply, and post-new-thread sections of your
    Invision Power Board, thus giving your visitors the ability to upload images directly. After upload,
    they may paste the images directly into their post box.'' CODE These instructions will
    help you to install 'ImageShack on your Site' into the reply, quick-reply, and
    post-new-thread sections of your Invision Power Board, thus giving your visitors the ability ....
  9. Creating A Simple Image Viewer
    Using Visual Basic 2005 Express Edition (4)
    I downloaded Microsoft's Visual Studio Express suite a few months ago, but only recently got
    around to installing it. I have been practising with Visual Basic and making some rather basic
    programs and utilities, but they contain most of the basic concepts. This tutorial will explain how
    to create a basic image viewer, and I will try to explain each step from beginning to end as clear
    as I can. To start you will need: Microsoft Visual Studio About 10-20 minutes free time OK,
    first open up the Visual Basic part of the Studio. I am using the 2005 Express version, so....
  10. Css Based Photo Gallery Code
    Fluid design for layout (3)
    Fluid Design Photo Gallery There are quite a few Topics here on the Trap17 Forum about how to
    set-up and use Photo Galleries and about the link code for getting from a Thumbnail Image to a full
    size Image and all that stuff, so I would like to take this "Photo Gallery" concept one step further
    without covering what others have already supplied instruction for. Usually, when there is a
    solution posted here for the code on "how-to-do-this", there are tables involved and the Links are
    placed inside Table cells. Tables are not neccesarilly a bad thing, but they were n....
  11. How To Stop Image Hot Linking
    for a selected directory. (17)
    Those of you that don't know what is meant by 'hotlinking', it is when someone directly
    links to an image on your site so it will display on their site. This is what is called
    'bandwidth theft' and being as accounts here have a limit on bandwidth, your bandwidth limit
    could be exceeded by someone else hotlinking to your images. As most users of cPanel will know,
    there is an option to disable hotlinking of images in the "Site Management Tools" section.
    However, this disables hotlinking to all directories, what if you only want to disable hotlinki....
  12. Image Rollovers In Javascript
    A Write-Once, Use-Anywhere Approach (11)
    Tutorial: Image Rollovers w/ Javascript, by Rob J. Secord, B.Sc. (SystemWisdom) See a
    working Sample of this Script! Download a ZIP containing all working files in this
    tutorial! Note: If you are not interested in reading this entire tutorial and/or have a basic
    understanding of the underlying concepts, you may safely skip to the Implementation section to get
    the code! Description : A Dynamic Image Rollover Script tested to work in 4 major internet
    browsers: MSIE, FireFox, Netscape and Opera. Using only Javascript combined with regular HT....
  13. How To: Change An Image When A User Clicks On It
    using both php and javascript (11)
    How To: Change An Image When A User Clicks On It using both php and javascript - a powerful
    combination I have seen quite a few how tos offering a method of doing this but none of which
    resembled my method of making use of both php and javascript. This code is fairly repetitive and
    most of the functions are easy to pick-up if you haven't heard of them before. Here it is...
    Create your two images. Call them anything you like, you'd just need to change their filenames
    in $imgano $imgayes. In fact with this script you can easily create more tha....
  14. Jalbum 5.2
    Gallery Building Software (0)
    Just thought I would create a tutorial for those who want to use a gallery on their site but
    don't know how. This tutorial looks at JAlbum 4.4.2, which you can get by going here GET JAlbum
    5.2 // Step 1 JAlbum allows you to create a photo album without even leaving its main page. Here
    you can select the image directory, output directory, common album settings and control the album
    generation. // Step 2 To select an image directory, just drag and drop an image folder onto the
    Image Directory bar. JAlbum can read photos in JPG, GIF and PNG formats as well as movie ....
  15. Transparent Scrollbars
    Coding Transparent Scrollbars (2)
    Why woud someone want a Transparent scrollbars you ask? Well fist of they do not cover too much of
    the image like the normal scrollbars. You can use transparent scrollbars for different kinds of web
    layouts such as popups, iframes, or scrolling div layers. For iframes, make sure you've inserted
    a background image for the table cell containing the iframe. You do not need to do that for
    scrolling div layers. Although, you cannot make the main scrollbar transparent unless you make it
    appear that way by selecting the same color for everything. After you code the scroll....
  16. Php Installed Modules Dynamic Reference Tool
    An effective tool for coding in PHP (4)
    PHP Installed Modules Dynamic Reference Tool A dynamic tool for referencing PHP modules and
    their associated routines, which are installed on your web-server. **Note: Uses only 2 functions
    built-in to PHPs core and should be easy to convert to a later version of PHP. This current version
    uses PHP4. Example: PHP Installed Modules Dynamic Reference Tool Abstract : As a PHP
    Developer, it is nice to know what functionality is available to you, and what you would have to
    implement yourself. Some of this functionality is provided for you by the PHP core,....
  17. Extending The Image Preloader With Php4
    Dynamically adds your images to Preloader! (3)
    Tutorial: Extending the Image Preloader with PHP4, by Rob J. Secord, B.Sc. (SystemWisdom)
    Second Tutorial in a Series of 2 Tutorials! Be sure to have read the First One here: "Image
    Preloader With Progress Bar Status" See a working Sample of this Script! (Note: Preloads
    100 images, some images are larger than others, and may take awhile for some people.)
    Description : A Tutorial for Extending the Image Preloader with PHP4 to Dynamically Populate the
    Array of Preloaded Images. This tutorial is the second in a series of 2 tutorials, and assume....
  18. Image Preloader With Progress Bar Status
    Pure Client-Side JavaScript tested in 4 Browsers! (23)
    Tutorial: Image Preloader with Progress Bar, by Rob J. Secord, B.Sc. (SystemWisdom)
    Description : A Tutorial for a Client-Side Image Preloader with Dynamic Real-Time Progress Bar
    Indicator written in JavaScript! Tested to work with 4 Major Internet Browsers: Firefox, MSIE,
    Netscape, Opera (Complete sample solution provided at end of tutorial, just put it on your
    web-server, add your images and go!) Intended Audience : Beginner to Intermediate Web
    Developers. Although this tutorial will cover some advanced aspects of JavaScript, I will try to
    explain....
  19. Roll-over Image Links With Css
    No preloading of images (2)
    Here is a way of having roll over image links without preloading images by using CSS and a table.
    It's very useful for a list of links as in a side bar menu or header. It also solves not having
    to make a seperate image for each different link by placing the desired text over the image. 1.
    First you need an image which comprises of the main link image, the 'mouse over' image link
    underneath plus you can have another for visited links. As for most roll over images, the images
    should be the same size. The above example - button.gif is 100x60px with each lin....
  20. A Little Introduction To 3d Studio Max
    How to make a simple abstract image (9)
    This tutorial will teach you the basics of making abstract images in 3D studio max. In this example,
    I used a simple sphere, and applied the “Noise” modifier. Then, I applied a transparent, blue,
    plastic-like material to spice up the whole thing. Let’s start. First, make a sphere by selecting
    the “Sphere” button in the “Standard Primitives” section, and draw somewhere in the center of the
    perspective view. We will set the size of the sphere later on. The sphere I made looks like this,
    yours can be different in size and color, but the only thing that is important is to....
  21. Easy Image Rotate Tutorial
    (0)
    Well, since I'm new, I don't know what has been posted and what hasn't, so here's an
    easy-to-use php tutorial! CODE <?php @header("Pragma: nocache");
    $URL1="Your Image Source"; $URL2="Your Image Source"; $URL3="Your
    Image Source"; $URL4="Your Image Source"; $URL5="Your Image Source";
    srand((double) microtime() * 1000); $random = rand(1,5);
    if($random == 1) @header ("Location: $URL1")....
  22. Simple Image Rotator
    randomly rotate images (6)
    First, It's really confusing. Do you know any tutorials on Image Manipulation on PHP?
    Here's another simple one: 1. Create a 5 image. 2. Rename them to something like:
    image1.jpg; image2.jpg; and so on... 3. Create your PHP file (rotation.php) 4. Enter the
    following code: CODE <?php header("content-type: image/jpeg");
    readfile("image".mt_rand(1,3).".jpg"); ?> 5. Execute your
    script.....

    1. Looking for image, gallery, hoverbox, php, solution, coding, hoverbox, image, gallery

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for image, gallery, hoverbox, php, solution, coding, hoverbox, image, gallery

*MORE FROM TRAP17.COM*
advertisement



Image Gallery Tutorial Using Hoverbox - A php solution to coding the Hoverbox Image Gallery



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE