VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: mircot80 on March 30, 2013, 11:55:51 AM

Title: Wrong image on facebook share
Post by: mircot80 on March 30, 2013, 11:55:51 AM
Hi,
I put facebook share and facebook like in virtuemart product but always it takes wrong picture.
This is the changes that I did:

1) At the beginning of the file: /templates/template1/index.php
I insert the following code:

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1&appId=1111111111111"; (with my id)
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

2) At the beginning of this file: components/com_virtuemart/views/productdetails/tmpl/default.php
I insert the following code:

<html>
   <head>
   <?php
   $og_type = 'article';
   $og_url = JURI::current();
   $og_image =  JRoute::_(JURI::base().$this->product->images[0]->file_url);
   $og_desc = $this->product->product_s_desc;
   $og_title = $this->product->product_name;
   
   $app =& JFactory::getApplication();
   $og_sitename = $app->getCfg('sitename');
   
   $doc = JFactory::getDocument();
   $doc->addCustomTag('<meta property="og:type" content="article"/>');
   $doc->addCustomTag('<meta property="og:url" content="'.$og_url.'"/>');
   $doc->addCustomTag('<meta property="og:site_name" content="'.$og_sitename.'"/>');
   $doc->addCustomTag('<meta property="og:image" content="'.$og_image.'"/>');
   $doc->addCustomTag('<meta property="og:description" content="'.$og_desc.'"/>');
   $doc->addCustomTag('<meta property="og:title" content="'.$og_title.'"/>');
   ?>
   </head>
</html>

3) And in a point that I choice I insert:

<fb:like send="true" width="450" show_faces="false"></fb:like>

This is a product of my site:
http://www.trevisoassistenza.it/shop/modem/modem-gsm-dual-band-seriale-digicom-8d0114-detail.html

With Firebug I find this tag (it seems correct):
<meta content="http://www.trevisoassistenza.it/images/stories/virtuemart/product/8d0114.jpg" property="og:image">
But the image is always wrong.

With this open graph test: https://developers.facebook.com/tools/debug/
It tell me:
Meta Tags In Body:   Your page has meta tags in the body instead of the head. This may be because your HTML was malformed and they fell lower in the parse tree.
Please fix this in order for the tags to be usable.

And

Like Button Tag Missing:   og:image is missing. The og:image meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.

Where am I doing wrong?
Thanks
Mirco
Title: Re: Wrong image on facebook share
Post by: mircot80 on March 31, 2013, 16:05:44 PM
My version of joomla is 2.5.9 and virtuemart 2.0.20b
Someone can help me?
Thanks
Title: Re: Wrong image on facebook share
Post by: mircot80 on April 02, 2013, 11:20:59 AM
Help me please......


Mod edit:  impatient bump message removed. Read  http://forum.virtuemart.net/index.php?board=114.0
Title: Re: Wrong image on facebook share
Post by: mircot80 on April 05, 2013, 09:44:28 AM
Is there a Facebook open graph forum?
Thanks
Mirco
Title: Re: Wrong image on facebook share
Post by: jenkinhill on April 05, 2013, 10:23:49 AM
No idea. We have nothing to do with Facebook. Just issues with VirtueMart itself. See http://forum.virtuemart.net/index.php?topic=108212
Title: Re: Wrong image on facebook share
Post by: mircot80 on April 17, 2013, 11:28:47 AM
I solved the problem by itself.
For those interested, I created a guide, can be found here (It's in italian):

http://www.trevisoassistenza.it/guide/joomla/24-joomla-inserire-in-virtuemart-i-pulsanti-di-facebook-mi-piace-e-invia.html (http://www.trevisoassistenza.it/guide/joomla/24-joomla-inserire-in-virtuemart-i-pulsanti-di-facebook-mi-piace-e-invia.html)