javascript - Facebook Like Button in Pretty Photo Image Gallery - Stack Overflow

On this site I used pretty Photo image gallery.The problem is - when a user clicks on the facebook lik

On this site I used pretty Photo image gallery. The problem is - when a user clicks on the facebook like button - on his news is displayed only the name of the site. what I would like is - when a user clicks fb LIKE button on a particular image, that image is shown on his news feeds. can you help me make this?

On this site I used pretty Photo image gallery. The problem is - when a user clicks on the facebook like button - on his news is displayed only the name of the site. what I would like is - when a user clicks fb LIKE button on a particular image, that image is shown on his news feeds. can you help me make this?

Share Improve this question edited Sep 24, 2012 at 19:08 Dantes asked Sep 15, 2012 at 14:20 DantesDantes 2,8916 gold badges28 silver badges35 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

When working with Facebook, always ALWAYS check your website url with the Facebook debugger.

Looks like the problem is that Facebook couldn't featch the image probarly, so you will need to add a meta tag so Facebook can know the desired image for the prvded URL.

Ex: <meta property="og:image" content="YOUR_IMAGE_PATH"/>

Update 1:

In order to modify the Meta tag value when the user changes the gallery image, you can use the following code to do so:

$("meta[property=og\\:image]").attr("content", YOUR_IMAGE_PATH);

note that we needed to escape the : character as mentioned in the documentation

Update 2:

you will need to alter those functions in order to make it to work:

    $pp_gallery.find('.pp_arrow_next').click(function(){
            $.prettyPhoto.changeGalleryPage('next');
        // here you will need to read the current image url, then assign it to our facebook line.
    $("meta[property=og\\:image]").attr("content", YOUR_IMAGE_PATH);
            $.prettyPhoto.stopSlideshow();
            return false;
        });

    $pp_gallery.find('.pp_arrow_previous').click(function(){
            $.prettyPhoto.changeGalleryPage('previous');
        // here you will need to read the current image url, then assign it to our facebook line.
$("meta[property=og\\:image]").attr("content", YOUR_IMAGE_PATH);
            $.prettyPhoto.stopSlideshow();
            return false;
        });

Use Facebook's OG Meta Tags

For images for instance :

<meta property="og:image" content="http://yourwebsite./img/img.png"/>

For more information, check out this : http://davidwalsh.name/facebook-meta-tags

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744218928a4563686.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信