0

I'm trying to show the product image when sharing a product on Facebook. The issue is that the image isn't added all the times. The first share is without image, the second one works.

    <?    
$og = [];
$og['title'] = $this->getTitle();
$og['site_name'] = Mage::app()->getStore()->getName();
$og['description'] = strip_tags($this->getDescription());
$og['url'] = $this->helper('core/url')->getCurrentUrl();

if(Mage::registry('current_product')):
    $product = Mage::registry('current_product');
    $og['title'] = $product->getName();
    $og['type'] = 'product';
    $og['image'] = $this->helper('catalog/image')->init($product, 'image');    
    $og['description'] = strip_tags(($product->getShortDescription()));
    $og['price:amount'] = Mage::registry('product')->getFinalPrice();
    $og['price:currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
elseif(Mage::registry('current_category')):
    $og['type'] = 'product.group';        
elseif((Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
    Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')) :
    $og['type'] = 'website';
else:
    $og['type'] = 'article';
endif;
?>
<? foreach($og as $key => $value): ?>
<meta property="og:<?= $key ?>" content="<?= $value ?>">
<? endforeach; ?>
filippo90
  • 367
  • 2
  • 3
  • 15
  • Use [OG debugger](https://developers.facebook.com/tools/debug/) I guess Your images are too small. – Bogdan Kuštan Sep 24 '15 at 16:09
  • I think that is not a problem related to the size of the images becouse is not a sistematic issue, sometimes it share the image, sometimes not. The OG Debugger show that the image was found even if not showed - [link](http://www.arreda.it) – filippo90 Sep 24 '15 at 16:19
  • 1
    Try this one: http://stackoverflow.com/a/32506991/1427878 (specifying image dimensions via OG meta tags as well.) – CBroe Sep 25 '15 at 10:32

0 Answers0