Hacking the Sociable WordPress Plugin for Image Rollovers
You might be wondering where the daily addition to the album list is. Surprisingly, there are none today. All my time was eaten up by those new, little images at the bottom of the posts. If you’re wondering what those are, they’re part of a WordPress plugin called Sociable. What they do is allow people to bookmark posts to social bookmarking sites like Digg or del.icio.us. Then, others can share and comment on the stories as a group. (More information on Social bookmarking from Wikipedia)
You may have noticed that yesterday they were colored, but today, they blend in a little more. That’s because I can’t leave things well enough alone. I spent a good few hours trying to hack the Sociable code to do image rollovers that only light up when you put your mouse over them. And that meant creating new images, figuring out how the rollovers should work, and figuring out what needed to be added to and hacked out of the original code to actually get it going.
The way it works is that each of the images you see is only half of an image. I took the original images, and created images like this:

Essentially, the only other thing that I did was resize some of the images to a standard size of 18×36 pixels (for simplicity’s sake) and make the top half a black and white copy of the bottom half.
That way, when we hover over the image, we can use the background-image property to have CSS tell the browser to look down 18 pixels to the bottom half, making the image appear colored. 2 images in 1. Exciting stuff, right? The code for each icon looks something like this:
a#fark {
display:block;
padding: 0px 1px;
width: 18px;
height: 18px;
float: left;
background-image: url(fark2.png);
background-position: 0 0;
background-repeat: no-repeat;
margin: 0 auto;
}
a#fark:hover {
background-position: 0 -18px;
}
Once an entry had been created for each bookmark on the list, I hacked out a few chunks of sociable.php to get it to work. And work it does, so I zipped up the mods for download for anyone needing it. I would highly suggest getting Sociable working before even contemplating implementing this mod because it’s late, I’m a hack, and my instructions are pretty poor.
If you have any questions other than “Did Tia Carrera have an album?” I’ll try to answer them.
Share, Bookmark, or E-Mail This Article
March 10th, 2006 at 10:59 am
Really impressive! Sociable V1.0 is about to be released with about 25 bookmarking sites supported. I’ll see if I can add this into the plugin, but it might be too late for this release — there has been a ton of upgrades.
Cheers!
March 12th, 2006 at 7:08 am
Nice. BTW, it is not really my code… I did nothing more than a few find and replaces… Thanks for the mention.
Nice work on your part
April 5th, 2006 at 11:39 am
[...] At the moment I’m looking at it as a good incentive for blog owners to prune down the number of sites they display, but it probably needs more help. One user had a creative solution to display icons in grayscale until they’re hovered over, and I’ll include that feature in the next version of Sociable (probably the next version). [...]
April 21st, 2006 at 6:53 am
[...] They’re Distracting and Weird-looking, Those Icons Yes. Yes, they are, aren’t they? All different colors, designs, styles. What is a self-respecting blogger to do? One guy made the images grayscale until you hovered over them. Peter Harkin, the author of Sociable, notes that he’s going to include this feature in the next version. However, I think I like my solution better. I’ve made the icons semi-transparent until you hover over them. That way, they still have their identifying colors, but they recede into my design a bit more. Let me know what you think! [...]
February 4th, 2008 at 6:35 am
Development on Sociable seemed to have stopped, so I have taken it upon me and given it a new home: WordPress Sociable 2.5.
February 10th, 2008 at 12:40 am
I have been visiting this site a lot lately, so i thought it is a good idea to show my appreciation with a comment.
Thanks,
Jim Mirkalami
PS: I am a single dad.