KexAri
KexAri

Reputation: 3977

Sharing a specific image on facebook using a share button

I currently have a share on facebook button with the following code:

<script>
    function fbShare(url, title, descr, image, winWidth, winHeight) {
        var winTop = (screen.height / 2) - (winHeight / 2)-100;
        var winLeft = (screen.width / 2) - (winWidth / 2);
        window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight+'' );
    }
</script>


<a href="javascript:fbShare('http://www.mywebsite.co', 'Fb Share', 'Facebook share popup', '', 520, 350)"><img class="right2" src="fblogo2.png"></a>

This works fine however the image facebook chooses to share from the site is randomly selected. I want to be able to specify one. Is there anyway of doing this?

Upvotes: 1

Views: 100

Answers (1)

DigitalDouble
DigitalDouble

Reputation: 1768

Yes. You can add a facebook meta tag to the specific page:

<meta property="og:image" content="http://graphics.myfavnews.com/images/logo-100x100.jpg" />

This is what facebook will use when you share that page.

Upvotes: 1

Related Questions