簡體   English   中英

漂亮照片圖像庫中的Facebook Like Button

[英]Facebook Like Button in Pretty Photo Image Gallery

在這個網站上,我使用了漂亮的照片圖庫。 問題是-當用戶單擊Facebook上的“贊”按鈕時-他的新聞僅顯示該站點的名稱。 我想要的是-當用戶單擊特定圖像上的fb LIKE按鈕時,該圖像將顯示在他的新聞提要中。 你能幫我做這個嗎?

使用Facebook時,請務必始終使用Facebook調試器檢查您的網站網址。

看起來問題在於Facebook無法隨意獲取圖像,因此您需要添加一個meta標簽,以便Facebook可以知道所輸入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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM