Don't bother looking for the 'social' buttons to share, save or bookmark this post: Leave your feedback in the comments and get the discussion started!

Posted on 15 February '10 \ Categories: blog, develop \ Tags: , , , ,

Gallery Image Sharing with Google Buzz

Google Buzz seems the next hot thing in the tech savy blog world…and I kinda like it. There are already a lot of tutorials for getting started as a developer/designer with it, but as always the one feature I need for my gallery site is missing: sharing gallery images with Google Buzz.

For some live demo and examples check out the sub categories, sub stats, tags or any single posts at the Fan-tas-tic! Inspiration Galleries: click on the Google Buzz button and see what the buzz is about!

As you may have noticed from de demo above I’ve got my social sharing and bookmark stuff also outside the loop, which makes this a bit trickier than it should.

That’s why my code is centrally in the functions.php of my WordPress theme. And here’s how full code behind the Google Buzz button looks like:
Buzz Code for Sharing Images

Let’s dissect the code for a quick analysis.

The URL

Line 1 contains the URL you want to buzz; the variable $share_link is the URL you want to pass through. You can replace this with the_permalink() if you are on a single post page.
I use the Buzz button also on other pages than the single post page. Therefore I need to use the following function in the functions.php:

function ftt_get_currenturl(){ return 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; }

The title

Line 2 contains the title we want to buzz: although you can use the_title() when on a single post page, I use wp_title(), because I use the Buzz button also on other pages.

The thumbnail

Line 3 contains the actual image we want to buzz, along with some optional text.
Already somewhere above this you should have the following statement to get the proper thumbnail for the current post (when on a single page) or the last thumbnail/post on the page, which should be satisfactory too:

$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');

The Result

That should do the trick! Now, when you click on the Google Buzz, you should get something like this:

You can play around and adjust stuff to your liking. Let me know in the comments, whether this works for your (gallery) site.

UPDATE

Note that something is messing the code displayed in this post! Maybe because I’ve just upgraded to WP 2.9.2!?
So I had to resort to screenshots…