iamnards
iamnards

Reputation: 217

How to display image in Facebook Sharer?

I'm using the code to display pop-up Facebook Sharer, but the glitch is, the image is not displaying.

<?php
    $title="My Wedding Lookbook! | BridalBook.ph 3rd Anniversary Promo";
    $url="http://www.bridalbook.ph/promos/bridalbook-3rd-year-anniv-promo/?preview=1";
    $summary="I just created my dream wedding lookbook! Getting married? Make your own on BridalBook.ph!";
    $image="http://pagsanjanpalmresort.com/moodboards/111.jpg";
?>

<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $title;?>&amp;p[summary]=<?php echo $summary;?>&amp;p[url]=<?php echo $url; ?>&amp;&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');"> 
Share on Facebook. 
</a>

What's gone wrong?

Upvotes: 3

Views: 8312

Answers (2)

Jaspal Singh
Jaspal Singh

Reputation: 1240

All the other parameters except for image url and Share url need to urlencoded.

Sample Javascript implementation follows

    imageUrl = 'http://pagsanjanpalmresort.com/moodboards/111.jpg';
    shareTitle = 'My%20Wedding%20Lookbook!%20%7C%20BridalBook.ph%203rd%20Anniversary%20Promo';
    desc = 'I%20just%20created%20my%20dream%20wedding%20lookbook!%20Getting%20married%3F%20Make%20your%20own%20on%20BridalBook.ph!';
    url = 'http://www.bridalbook.ph/promos/bridalbook-3rd-year-anniv-promo/?preview=1';

    window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + shareTitle + '&p[summary]=' + desc + '&p[url]=' + url + '&p[images][0]=' + imageUrl + '', 'sharer', 'toolbar=0,status=0,width=626,height=436');

Upvotes: 3

GusRuss89
GusRuss89

Reputation: 1404

The Open Graph meta tags, specifically og:image, might help, depending on how you were wanting it to be displayed. Using the open graph tags, your website will appear as a link with a thumbnail. Clicking on the thumbnail will go to the url, not show the full photo within facebook.

Upvotes: 0

Related Questions