在这个网站上,我使用了漂亮的图片库。 问题是 - 当用户点击 facebook 的 like 按钮时 - 在他的新闻上只显示网站的名称。 我想要的是 - 当用户在特定图像上单击 fb LIKE 按钮时,该图像会显示在他的新闻提要中。 你能帮我做这个吗?
最佳答案
在使用 Facebook 时,始终始终使用 Facebook debugger 检查您的网站 url .
看起来问题是 Facebook 可能无法获取图像,因此您需要添加一个元标记,以便 Facebook 可以知道 prvded URL 所需的图像。
Ex: <meta property="og:image" content="YOUR_IMAGE_PATH"/>
更新 1:
为了在用户更改图库图像时修改元标记值,可以使用以下代码来实现:
$("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;
});
关于javascript - 漂亮图片库中的 Facebook Like 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12438146/