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

Dan*_*tes 5 javascript jquery jquery-plugins facebook-like prettyphoto

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

Moh*_*lam 5

使用Facebook时,请务必使用Facebook调试器检查您的网站网址.

看起来问题是Facebook无法预测图像,因此您需要添加元标记,以便Facebook可以知道所提供的URL的所需图像.

Ex: <meta property="og:image" content="YOUR_IMAGE_PATH"/>
Run Code Online (Sandbox Code Playgroud)

更新1:

为了在用户更改图库图像时修改元标记值,您可以使用以下代码执行此操作:

$("meta[property=og\\:image]").attr("content", YOUR_IMAGE_PATH);
Run Code Online (Sandbox Code Playgroud)

请注意,我们需要转义文档中:提到的角色

更新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;
        });
Run Code Online (Sandbox Code Playgroud)