jQuery image scaler

I've been tinkering around with jQuery a bit lately (see the show/hide sidebar trick above). I know virtually nothing about javascript, but jQuery allows a guy like me to do some pretty cool tricks and it has a relatively short learning curve as it is very intuitive and uses standard CSS selectors to do its work.

One of the problems I've run into through several theme changes on my blog is the size of images in my posts. The last time I changed themes I shrank the width of the content area from around 510px to more like 460px. Most of the images I had placed in posts were somewhere around 500px wide, which made them overflow into the sidebar area. I looked into a few different ways to fix this, and one approach was to use CSS to solve the problem.

.post img {
max-width:440px;
width: expression(this.width > 440 ? 440: true);
}

Internet Explorer doesn't support the max-width attribute, so the width: expression mumbo jumbo is supposed to trick it into shrinking the image. It seemed to work fine, until I visited my blog from my aunt and uncle's Mac a few months ago. The browser shrunk the width but not the height, leaving a strange looking, vertically stretched version of an image in this post. Not good.

I looked around to see if there was some jQuery code out there that automatically shrank an image if it was wider than a certain width. I didn't find anything out there, so I wrote my own code.

The following image is 1000 x 750 pixels, but jQuery shrinks it down to 440px wide so it fits perfectly as it should.

Tess Clementine

Enable/disable scaling

The code is pretty simple. You have to configure the max width for the images and also the CSS selector code so it knows which images to scale. After that jQuery examines each image to see if it is wider than the max width. If it is, it proportionally resizes the image down to the max width. I thought it would also be nice to allow the visitor to view the full-sized image, so jQuery turns the scaled down image into a link to the original.

Of course, in a perfect world one would size all of his images to fit the new layout and conserve bandwidth. Also, if a visitor has javascript disabled they will see the full-sized image, which may or may not bother you. Still, this seems like a pretty simple solution to keep large images from breaking your page layout.

You can view the sample code here. It tested fine in IE6, IE7, and Firefox 2.0, all on Windows. In Opera it worked sometimes, but not others (?). Let me know if you find a bug and/or if you have any browser optimization tips.

Elf you.

OfficeMax wants you to know that you can go elf yourself this Christmas. Amanda already elfed the Wittmann family (sans Tess) this morning. See the results here.

Image is everything

I'm not sure that even one of these could have made this season look any better.

Almost there

Pete turns four on December 7th, and I'm starting to get excited! I think he's finally intellectually ready to understand that I love him and want to have a personal relationship with him. Even from before he was born, I have had a deep desire to express my love for him; to embrace him as my son, to provide for him and nurture him, to instruct him and discipline him. The only problem is that I don't want to force my love on him, thereby violating his free will. What if he doesn't want me to love him? What if he chooses to reject my love? For me to force it on him would be unjust and perhaps even sadistic. It would be hateful, not loving, for me to force my love upon him against his will.

So, I've been waiting. I keep looking for signs that he's ready. He's getting really good at his A-B-C's, and he can count *way* past ten. But, is he old enough to make a decision this important? What if he can't clearly articulate what it is that he is choosing? What if he is too young to fully understand what it means to make a life-long commitment to accept me as his own personal father?

So, I continue to withhold my love from him until he's ready and able to tell me that he wants it. Until then, I'll just have to keep waiting for the time when he decides whether or not he wants to be a Wittmann. Man, I can hardly wait!

(In other words, if you think a son needs to be able to articulate the propositional truth that he loves his Father and his Father loves him in order for it to *count*, I think you're nuts.)

Live together, die alone

Gloria

Heard echoing throughout the state of Nebraska on Saturday:

Glo-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-ria… in excelsis T.O.

…press two

Just in time for the holiday season, we had a friendly visitor come down the chimney and into our home last night. Only instead of being jolly, fat, and dressed in red this little guest was little, brown, and possibly rabid.

At about 1:30 in the morning Amanda thought she heard something. No, that's not quite right. She thought she had heard something AND felt it fly past her in our bed. She did her best to collect herself and listened for "it" again. When she heard it in the bathroom she woke me up, saying that there was, um, something in the bathroom. Still in a stupor, I asked her to elaborate. She said that there was "an animal… or a bird… in the bathroom." I listened for it for a moment and then heard a clicking, rustling sound from that direction.

I jumped out of bed, threw on some jeans, grabbed the aluminum baseball bat that I keep around for occasions such as this, and went on patrol. I flipped on the light in the bathroom and… nothing. I proceeded down the hall toward the "school room" and looked inside. It was still dark, but there was enough light from the hall light that I could see in. That's when I saw it. Continue reading this post »

TO needs your vote

ESPN-U is holding a vote for the "Greatest College Football Coach of All Time" and, as you might expect, Dr. Tom is on the list of candidates. As of my vote a minute ago, Coach Osborne has 53% of the vote, with Bear Bryant in second with 33%. It's worth noting that Barry Switzer has 2% of the vote at this time.

Head on over and cast your vote for Tom Osborne, the Greatest College Football Coach of All Time. Voting Ends 12/01/07.

Oh, it's also worth noting that Bill Callahan's name isn't on the list either…

Busted

For some reason the theme I normally use on the ol' blog is acting up. I don't really have time to troubleshoot it right now, so I just picked an out of the box theme and threw it up. Hopefully I'll be able to get some time to fix the old one before too long.

tess.mikewittmann.com

If you're looking for more pictures and stories about the new baby, you can head on over to Tess' brand-spankin' new website.