SIDEBAR
»
S
I
D
E
B
A
R
«
How To Create A ‘Simple’ Online Photo Gallery
Jun 6th, 2009 by Michael McKennedy

Tutorial | June 2009 | M.McKennedy

click for a larger view

example photo gallery - click for a larger view

Let me guess, you are a website designer (or aspiring to be) and you want an easy way to manage/create online photo galleries? It’s your lucky day because I have a very simple solution for you using Google’s Picasa and a plug-in called ‘SimpleViewer’. The best part about all of this is that installing and using these nearly automated photo gallery creation tools is 100% free and really easy to do. Read on…

Note: This tutorial assumes that you have a web host and you have some working knowledge of website design and HTML. For a preview of the kind of image gallery I am talking about take a look at the May 2009 version of my ‘Things I Saw’ Photo Galleries. Or take a look at all the galleries here.

First things first: If you are not familure with Picassa – take a look at this free download page. Download and install Picasa and play around with it. You can edit, organize, and if you don’t have your own website you can upload to a free online photo album – (Picasa Web Albums provides 1 gigabyte of free storage) and share these photos with your friends and family but you will not be able to customize the photo viewer template.

Second: Download and install SimpleViewer (it’s a free, customizable Flash image viewing application – you do not need to know any Flash what-so-ever!)

Third: Open Picasa. Select the images you want to make a gallery from (to select multiple images you can hold down the CTRL key as you select each image, or to select a group of images click the shift key and select a range of images), and click Folder -> Export as HTML Page… Select your image size and gallery title. In the Select a Web Page Template page, select SimpleViewer. Click Finish. The gallery will be generated and displayed in a new browser window. Captions added in Picasa will show as captions in SimpleViewer.

Fourth: After the HTML page has been exported you can make adjustments – to adjust the number of rows and columns for the thumbnail version of the images you will need to open (using the HMTL or text editor of your choice) the auto-generated file called gallery.xml. In this file you will find two editable variables (plus more) – thumbnailColumns=”3″ thumbnailRows=”4″. Change the numbers to the values of your choice and save the file. Just keep in mind that if you change thumbnailRows to “40″ the template might not look so good!

Other photo gallery template options

TiltViewer example - click for a larger view

TiltViewer example - click for a larger view

TiltViewer - is my next choice of free online photo gallery templates. TiltViewer is a customizable 3D image display template. Images can be flipped to show a description text and an optional link. Designed to provide a fun, intuitive user experience. If you are looking for something a bit more flashy than SimpleViewer, TiltViewer should be your choice. – to install, follow the same instructions as for SimpleViewer. Click on the image on the right to view a sample of the photo gallery or take a look at my Things I Saw photo gallery from April 2009 for a working example. There are also other image viewers AutoViewer, and PostcardViewer.

Online photo galleries can be both simple and free using Picasa and the terrific Flash based templates created by Airtight Interactive.com.  With a little bit of HTML (Hyper-Text Markup Language) and CSS (Cascading Style Sheets) experience you can have your images displayed in an visually impressive online gallery in just a few simple minutes.

JavaScript onMouseOver Link -> Change Div’s Background-Image
Feb 25th, 2009 by Michael McKennedy

Article | HTML/JavaScript Tutorial | Feb 2009 | M.McKennedy

So you want to know how to change a background image when a link is hovered over and back to the original onMouseOut but you don’t know much HTML and/or JavaScript?  Perfect… take a look at this simple tutorial on how to use the Document Object Model (DOM), the onMouseOver and onMouseOut event handlers and a bit of JavaScript to make the magic happen.

Now before I jump into this I must say.  I am not an expert in JavaScript nor HTML but I was bored today so I decided that I wanted to create a “onMouseOver” event to trigger the background image of a Div to display add odd image of myself (this is for my personal website of course, and all in good fun) when my name is hovered over with the mouse pointer. I wanted the image to appear as the background while keeping the text of the paragraph “on top” of the image, so it has looks like I am trapped beneath the text, yes, I know…not the most appropriate use of my time but it was enjoyable. As the mouse pointer is moved from the link the image goes back to a white background.

I do understand that there are many different ways to achieve this same effect.  Some “better” than others.  So if you have come here to add snotty comments about crappy HTML, JavaScript or CSS coding then you should just leave now.  (Well, of course you can stay and read on…just don’t leave any negative feedback unless you have something constructive to go with it.  If you know of other ways to achieve the image roll over effect then please feel free to post and post often!

I searched various forums and found plenty of different methods posted by a variety of different skill leveled authors but none that suited my “copy and paste” desires.  There were a host of HTML tutorials on how to change the background color when a link was clicked.  Tons of posts where the subject of the post and/or article was lost in a blur of childish bickering over coding semantics.   I was looking for a quick and easy way so I reworked my search term and entered them over and over into the almighty Google to no avail.  I needed to dig in to find out how it all worked so I changed my search terms to “HTML Document Object Model “.   If I was going to do this I needed to learn about how HTML page elements can be accessed and therefore manipulated.

Eventually I stumbled upon (and in hindsight should have been the first place I looked)  http://www.w3schools.com/ and specifically their section on the HTML Document Object Model – http://www.w3schools.com/htmldom/default.aspI was able to figure it out and it’s really quite simple.  Here is a link to what I did – hover your mouse over the word Michael in the first paragraph to watch the image appear. Move your mouse pointer away from the link to watch the background return to white.

Below are two static images of what happens with the mouse over, click on them for a larger view or just go to McKennedy.org and see it for yourself.

Moving the mouse pointer over the word Michael creates triggers the onMouseOver event. (click for a larger view)

Hover Over This Link To Change The Div's Background Image (click for larger view)

The onMouseOver Event triggers the changing of the divs background image. (click for a larger view)

Hovering Over The Link Causes The onMouseOver Event To Change The Background Image Of The Div

If you want to practice this on your own here are links to the two images:

Michael
Spacer

Here is how I did it.

<html><title></title><body><head>I put following section between the head tags  – like this</head><body></html> tags:

<!– Image Roll –>
<script type=”text/javascript”>
function changeStyle()
{
document.getElementById(“imageRoll”).style.backgroundImage=”url(images/profile/from-above-thumbs-up.jpg)”;
}
function changeStyleBack()
{
document.getElementById(“imageRoll”).style.backgroundImage=”url(images/spacer-2×2-white.jpg)”;
}
</script>
<!– End Image Roll –>

The Div that changes background when the link is hovered over is below:  This belongs somewhere between the <body></body> tags.

<div id=”imageRoll” style=”background-repeat:no-repeat”>

<p style=”font-size: 1.2em”>Some Opening Title – Something BOLD – Eye Grabbing</p>

<p>Here is where I write some text, yes, some text and then I put some more and try to use words that are more than five characters.  My name is <a href=”#” onmouseover=”changeStyle()”; onmouseout=”changeStyleBack()” title=”Michael Gives Two Thumbs Up To His Own Web Site>Michael</a>,

and if this code was live then when you hovered over the word “Michael” you would have seen an image of me appear beneath this text.</p>

</div>

To put the entire thing together:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>onMouseOver Change Div Background Image Example</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<!– Image Roll Over Code –>
<script type=”text/javascript”>
function changeStyle()
{
document.getElementById(“imageRoll”).style.backgroundImage=”url(images/profile/from-above-thumbs-up.jpg)”;
}

function changeStyleBack()
{
document.getElementById(“imageRoll”).style.backgroundImage=”url(images/spacer-2×2-white.jpg)”;
}
</script>
</head>
<body>
<div id=”imageRoll” style=”background-repeat:no-repeat; width:348px; height:261px”>
<p style=”font-size: 1.2em”>Some Opening Title – Something BOLD – Eye Grabbing</p>
<p>Here is where I write some text, yes, some text and then I put some more
and try to use words that are more than five characters. My name is <a href=”#” onmouseover=”changeStyle()” onmouseout=”changeStyleBack()” title=”Michael Gives Two Thumbs Up To His Own Web Site”>Michael</a>,
and if this code was live then when you hovered over the word &quot;Michael&quot; you
would have seen an image of me appear beneath this text.</p>
<p>I set the height in the style of this div because this text wasn’t filling
the space to allow the entire background image to appear when the link is
hovered over.</p>
</div>
</body>
</html>

The code above is valid XHTML Transitional 1.0.  and has been tested in Firefox 3.0.6, IE 7, Google Chrome, Opera 9.2, and Safari (For Windows) 3.2.1.

I thought about pre-loading the image using JavaScript or CSS but then I realized that the image itself is only 18.9 KB therefore there should not be much time spent waiting for the background image to load.

So there it is…and it’s pretty simple too.  A short and sweet way to solve the big JavaScript onMouseOver onMouseOut Background-Image changing mystery.  Copy, Paste and modify the above code to fit your needs.

Horizontal Sliding JavaScript Menu Highlighter – Sweet!
Jan 3rd, 2009 by Michael McKennedy

HTML – JavaScript – CSS | Jan 2009 | M.McKennedy

I stumbled upon this lightweight (1kb) horizontal sliding JavaScript menu highlighter yesterday – simple to implement, cross-browser compatible and free!  This morning I replaced the existing navigation on McKennedy.org with this sweet-looking version from www.leigeber.com.

McKennedy.org got a make-over this morning which bumped up the site version from 2.0 to 3.0.  I replaced the navigation with a nifty sliding JavaScript menu highlighter.  The old navigation was a bit boring.  The coding was fine and lightweight and relied on CSS using background images but really there wasn’t any flare – at all!  Now that I look back at it I am wondering, “what the hell was I thinking?”

2008 Navigation on McKennedy.org

2008 Navigation on McKennedy.org

The new sliding JavaScript menu highlighter is pretty slick. On mouseover the highlighting “slides” over the where the mouse pointer was and then slides back to it’s original place. It’s very cool!

2009 Navigation on McKennedy.org

2009 Navigation on McKennedy.org

The original sliding JavaScript menu highlighter script can be found here.  To implement the new navigation was really simple.

<div class="menu">
    <ul id="menu">
        <li><a href="some-web-page.html" title="Some Web Page">Web Page 1</a></li>
        <li><a href="some-web-page-2.html" title="Some Web Page">Web Page 2</a></li>
        <li><a href="some-web-page-3.html" title="Some Web Page">Web Page 3</a></li>
        <li value="1"><a href="some-web-page-4.html" title="Some Web Page">Web Page 3</a></li>
    </ul>
    <div id="slide"></div>
</div>

To set the default menu item use this sytax value=”1″ (as seen above).

The CSS side of it consists of a mere 6 lines which I adjusted below for formatting reasons:

 {
margin:0; padding:0;
}

.menuSlide {
position:relative;
background-color:#000000;
height:35px;
width:100%;
}

.menuSlide ul {
list-style:none;
z-index:10;
position:absolute;
z-index:100;
padding:9px 5px;
}

.menuSlide li {
float:left;
}

.menuSlide a, .menuSlide a:active, .menuSlide a:visited, .menuSlide a:hover {
text-decoration:none;
color:#FFF; padding:10px;
}

#slide {
position:absolute;
top:6px;
height:24px;
background:#ffcc33;
z-index:10;
}

The JavaScript (which is a bit advanced for me) side of things is also somewhat compact. I made a few formatting changes below so the code will fit on this page.

var menuSlider=function(){
	var m,e,g,s,q,i; e=[]; q=8; i=8;
	return{
		init:function(j,k){
			m=document.getElementById(j);
                        e=m.getElementsByTagName('li');
			var i,l,w,p; i=0; l=e.length;
			for(i;i<l;i++){
				var c,v; c=e[i];
                                v=c.value;
if(v==1){s=c; w=c.offsetWidth; p=c.offsetLeft}
				c.onmouseover=function(){menuSlider.mo(this)};
                                c.onmouseout=function(){menuSlider.mo(s)};
			}
			g=document.getElementById(k);
                        g.style.width=w+'px';
                        g.style.left=p+'px';
		},
		mo:function(d){
			clearInterval(m.tm);
			var el,ew;
                        el=parseInt(d.offsetLeft);
                        ew=parseInt(d.offsetWidth);
			m.tm=setInterval(function(){menuSlider.mv(el,ew)},i);
		},
		mv:function(el,ew){
			var l,w; l=parseInt(g.offsetLeft);
                        w=parseInt(g.offsetWidth);
			if(l!=el||w!=ew){
				if(l!=el){var ld,lr,li; ld=(l>el)?-1:1;
                                lr=Math.abs(el-l); li=(lr<q)?ld*lr:ld*q;
                                g.style.left=(l+li)+'px'}
				if(w!=ew){var wd,wr,wi; wd=(w>ew)?-1:1;
wr=Math.abs(ew-w); wi=(wr<q)?wd*wr:wd*q; g.style.width=(w+wi)+'px'}
			}else{clearInterval(m.tm)}
}};}();

To initialize the script simply call the function:

menuSlider.init('menu','slide')

For example:

<body onload="menuSlider.init('menuSlide','slide')">

To see this in action go to McKennedy.org.

To download the script from the original source and to check out more of what Mr. Leigeber has to offer (free for both personal and commercial use) go here.

I have personally tested this in the follow web browsers and did not find any issues:

  • Firefox – v 3.0.5
  • Google Chrome – v 1.0.154.36
  • Internet Explorer – v 7.0
  • Safari (for Windows) – v 3.2.1
  • Opera – v 9.51

Thanks Mr. Leigeber!

Photography and other stuff....
© Michael McKennedy | McKennedy.Org