How to share the featured image by default on social sites

I wanted to share with the group the resolution to a problem I was having with my site at http://mybizpower.com. I installed the floating social bar and my issue was that my widget images were sometimes being used instead of my featured image, when you click on the bar to share the post or page. It was really upsetting to see a banner ad or side bar image instead of my post image on my facebook, linkedin, google plus etc. So I did a little digging and found this code.
You put it in your header.php between the <head> and </head>
and voila! it worked like a charm. No heavy plugin, no pulling hair out.
Here's the code:

<?php if ( is_single() and function_exists('has_post_thumbnail') and has_post_thumbnail($post->ID) ) : ?> <link rel="image_src" href="<?php $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium'); echo $thumb[0]; ?>" /> <?php endif; ?>

Cheers!