在这个网站上,我使用了漂亮的照片库。问题是,当用户点击类似facebook的按钮时,他的新闻只显示网站的名称。我想要的是——当用户点击某个特定图像上的fbLIKE按钮时,该图像就会显示在他的新闻推送上。你能帮我做这个吗?
使用Facebook时,请始终使用Facebook调试器检查您的网站url。
看起来问题是Facebook可能无法观察到图像,所以你需要添加一个元标签,这样Facebook才能知道所需的prvded URL图像。
Ex: <meta property="og:image" content="YOUR_IMAGE_PATH"/>
更新1:
为了在用户更改图库图像时修改Meta标签值,您可以使用以下代码进行修改:
$("meta[property=og\:image]").attr("content", YOUR_IMAGE_PATH);
注意,我们需要转义文档中提到的:
字符
更新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;
});
使用Facebook的OG元标签
例如,对于图像:
<meta property="og:image" content="http://yourwebsite.com/img/img.png"/>
有关更多信息,请查看以下内容:http://davidwalsh.name/facebook-meta-tags