Zen Cart Logo
Forums / All Other Contributions/Addons / Facebook LIKE button adds wrong picture

Facebook LIKE button adds wrong picture

Views: 2,915

Results 1 to 16 of 16
16 Mar 2012, 7:18 PM
#1
rocketfoot avatar

rocketfoot

New Zenner

Join Date:
Mar 2009
Posts:
64
Plugin Contributions:
0

Facebook LIKE button adds wrong picture

I just added this small edit to my cart and it works great except for one minor issue...when you comment on an item, it posts to your facebook page but the image that is automatically attached is not from what you just liked! Is there any known way to fix this?

Here is a link to the edit I did: http://www.zenflavor.com/add-facebook-like-button-to-your-zen-cart-product-pages.html

My cart: https://www.bigmacktrucks.com/store/
Version: 1.38a

Thanks in advance for any info!

19 Mar 2012, 10:18 AM
#3
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

Yes, add this code to your html_header.php

<meta property="og:title" content="<?php echo META_TAG_TITLE; ?>" /> <meta property="og:type" content="product" /> <meta property="og:site_name" content="<?php echo STORE_NAME; ?>" /> <meta property="og:fb_admin" content="your Facebook admin number if you're using FB insights" /> <?php if (isset($_GET['products_id'])) { // use products_image if products_id exists $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'"); $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image']; } if ($fb_image == '') { // if no products image, use the default image if enabled $fb_image = 'insert a default image url here'; } if ($fb_image != '') { ?> <meta property="og:image" content="<?php echo $fb_image; ?>" /> <?php } ?>
19 Mar 2012, 11:47 AM
#4
rocketfoot avatar

rocketfoot

New Zenner

Join Date:
Mar 2009
Posts:
64
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

dgent:

Yes, add this code to your html_header.php

<meta property="og:title" content="<?php echo META_TAG_TITLE; ?>" /> <meta property="og:type" content="product" /> <meta property="og:site_name" content="<?php echo STORE_NAME; ?>" /> <meta property="og:fb_admin" content="your Facebook admin number if you're using FB insights" /> <?php if (isset($_GET['products_id'])) { // use products_image if products_id exists $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'"); $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image']; } if ($fb_image == '') { // if no products image, use the default image if enabled $fb_image = 'insert a default image url here'; } if ($fb_image != '') { ?> <meta property="og:image" content="<?php echo $fb_image; ?>" /> <?php } ?>What is the path to html_header.php? I can't seem to locate it in my FTP??
19 Mar 2012, 1:05 PM
#5
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

includes/templates/YOUR_TEMPLATE/common

19 Mar 2012, 2:42 PM
#6
rocketfoot avatar

rocketfoot

New Zenner

Join Date:
Mar 2009
Posts:
64
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

dgent:

includes/templates/YOUR_TEMPLATE/common

OK, found that but now, where do I add your code? I tried adding to the top of the page and it killed the online cart...

19 Mar 2012, 3:25 PM
#7
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

Its metatags, so add it under the metatag title tag.

<title><?php echo META_TAG_TITLE; ?></title>
19 Mar 2012, 4:25 PM
#8
rocketfoot avatar

rocketfoot

New Zenner

Join Date:
Mar 2009
Posts:
64
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

dgent:

Its metatags, so add it under the metatag title tag.

<title><?php echo META_TAG_TITLE; ?></title>

OK, that worked a little better, but I got an error on the page that linked to this detail on Facebook:

The page failed to provide a valid list of administrators. It needs to specify the administrators using either a "fb:app_id" meta tag, or using a "fb:admins" meta tag to specify a comma-delimited list of Facebook users.

19 Mar 2012, 5:34 PM
#9
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

Sorry, yes the fb admin line should have said..

<meta property="fb:admins" content="youradminnumberhere" />
20 Mar 2012, 10:07 AM
#10
rocketfoot avatar

rocketfoot

New Zenner

Join Date:
Mar 2009
Posts:
64
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

That seems to work! I did get the proper photo in the Facebook post however, I am still getting an error after I LIKE it on my shopping page...

The page failed to provide a valid list of administrators. It needs to specify the administrators using either a "fb:app_id" meta tag, or using a "fb:admins" meta tag to specify a comma-delimited list of Facebook users.

Here is a screen cap of the error:

20 Mar 2012, 10:57 AM
#11
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

Have you entered your facebook admin number as its telling you to the metatag?

If you havent set up an admin page, go to the Facebook insights page and add your domains. This will give you the admin id to add to the meta-tag.

20 Mar 2012, 8:50 PM
#12
rocketfoot avatar

rocketfoot

New Zenner

Join Date:
Mar 2009
Posts:
64
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

dgent:

Have you entered your facebook admin number as its telling you to the metatag?

If you havent set up an admin page, go to the Facebook insights page and add your domains. This will give you the admin id to add to the meta-tag.

Thank you so much for the help! Facebook baffles me...I found my insights page, but I can't find my admin number? Where should I look? Sorry for the dumb questions!

21 Mar 2012, 9:12 AM
#13
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

https://www.facebook.com/insights/

Click on the 'insights for your website' green button on the top right.

Add your domain, and then it will create the metatag for you.

From this insights page you can get demographic info from your like button regarding shares, age groups etc..

31 Jul 2014, 8:22 PM
#14
loveofthehorse avatar

loveofthehorse

New Zenner

Join Date:
Jul 2014
Location:
Blanchard, Idaho USA
Posts:
21
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

I'm a bit perplexed. I was running 1.5.1 and was getting the correct image. Recently updated to 1.5.3

What I'm finding now is that if I link to one of my preexisting products the link goes up in facebook with the right image.

The item I've added since the update doesn't bring up the right image. Pinterest gets the right image.

metatag appears to be correct and old products post correctly, just not the new ones.

Any thoughts?

Here is the item which posts the wrong image to facebook

http://loveofthehorse.com/index.php?main_page=product_info&cPath=22_154&products_id=757

1 Aug 2014, 1:48 AM
#15
loveofthehorse avatar

loveofthehorse

New Zenner

Join Date:
Jul 2014
Location:
Blanchard, Idaho USA
Posts:
21
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

Even more interesting, when I pull the URL and just past it into facebook, I'm getting the wrong image more often then the correct on. This points not to the like code but more like the database isn't serving the correct image???? Doesn't make sense as the page always gets the right image

When I view the source view from the page it sure appears to reference the correct image. In this case

<meta property="og:image" content="http://loveofthehorse.com/images/melissa-doug-giant-stuffed-horse.jpg" />

loveofthehorse:

I'm a bit perplexed. I was running 1.5.1 and was getting the correct image. Recently updated to 1.5.3

What I'm finding now is that if I link to one of my preexisting products the link goes up in facebook with the right image.

The item I've added since the update doesn't bring up the right image. Pinterest gets the right image.

metatag appears to be correct and old products post correctly, just not the new ones.

Any thoughts?

Here is the item which posts the wrong image to facebook

http://loveofthehorse.com/index.php?main_page=product_info&cPath=22_154&products_id=757

23 Dec 2014, 9:20 PM
#16
loveofthehorse avatar

loveofthehorse

New Zenner

Join Date:
Jul 2014
Location:
Blanchard, Idaho USA
Posts:
21
Plugin Contributions:
0

Re: Facebook LIKE button adds wrong picture

Finally figured out why the wrong image posting in social media

In order to speed up image loads, if an image didn't need to be square, but was either tall or wide, Zencart handled it fine. So the image might be 180px by 90px

Facebook and pinterst wouldn't recognize these, I got no valid image or it just selected the next available image it like. Hence why it posted the "wrong" picture

Solution was to pad the images and square them up. On an image that didn't get pulled right, resized and was then getting the right image posted