在这个网站上,我使用了漂亮的照片图片库。问题是,当用户点击facebook的like按钮时,他的新闻只会显示网站的名称。我想要的是-当用户点击fb喜欢按钮在一个特定的图像,该图像显示在他的新闻馈送。你能帮我做这个吗?
发布于 2012-09-15 14:25:26
当与Facebook合作时,一定要用Facebook debugger检查你的网站地址。
看起来问题是Facebook不能很好地显示图片,所以你需要添加一个meta标签,这样Facebook才能知道所需的图片对应的URL。
Ex: <meta property="og:image" content="YOUR_IMAGE_PATH"/>
更新1:
为了在用户更改图库图像时修改Meta标签值,您可以使用以下代码来执行此操作:
$("meta[property=og\\:image]").attr("content", YOUR_IMAGE_PATH);
注意,我们需要转义documentation中提到的:
字符
更新2:
您需要更改这些函数才能使其正常工作:
$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;
});
发布于 2012-09-15 14:23:25
使用Facebook的OG Meta标签
以镜像为例:
<meta property="og:image" content="http://yourwebsite.com/img/img.png"/>
有关更多信息,请查看以下内容:http://davidwalsh.name/facebook-meta-tags
https://stackoverflow.com/questions/12438146
复制