Facebook Like Button in Pretty Photo Image Gallery

On this site I used a beautiful photo gallery. The problem is that when the user clicks the facebook button as a button, only the site name is displayed on his news. what I would like is when the user presses the fb LIKE button on a particular image, that image is displayed in his news feeds. can you help me do this?

+5
source share
2 answers

When working with Facebook, ALWAYS ALWAYS check the URL of your website using the Facebook debugger .

It seems that the problem is that Facebook was not able to play the image in a weird way, so you will need to add a meta tag so that Facebook can find out the desired image for the prvded URL.

Ex: <meta property="og:image" content="YOUR_IMAGE_PATH"/>

Update 1:

To change the meta tag value when changing the gallery image, you can use the following code:

$("meta[property=og\\:image]").attr("content", YOUR_IMAGE_PATH);

note that we needed to avoid the character :as indicated in the documentation

Update 2:

you will need to modify these functions to make it work:

    $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;
        });
+5
source

Use Facebook OG Meta Tags

For images, for example:

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

For more information check out this: http://davidwalsh.name/facebook-meta-tags

0
source

All Articles