Facebook在漂亮的照片图库中喜欢按钮

时间:2012-09-15 14:20:02

标签: javascript jquery jquery-plugins facebook-like prettyphoto

在这个网站上我使用了漂亮的照片图库。 问题是 - 当用户点击facebook like按钮时 - 在他的新闻上只显示该网站的名称。 我想要的是 - 当用户点击特定图像上的fb LIKE按钮时,该图像会显示在他的新闻源上。 你可以帮我做这个吗?

2 个答案:

答案 0 :(得分:5)

使用Facebook时,请始终使用Facebook debugger检查您的网站网址。

看起来问题是Facebook无法预测图像,因此您需要添加元标记,以便Facebook可以知道所提供的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;
        });

答案 1 :(得分:0)

使用Facebook的OG元标记

例如对于图像:

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

有关详情,请查看:http://davidwalsh.name/facebook-meta-tags

相关问题