php - Opencart dynamic OG meta tag -
my site http://goo.gl/awqnd9
opencart 1.5.5.1
i utilize codes dynamically product images
<meta property="og:image" content="<?php echo $thumb; ?>"/>
or
<meta property="og:image" content="<?php echo _get['image] ?>"/>
or
<meta property="og:image" content="<?= $_get['image'] ?>" />
but no result. every time fb shows store logo , proper title proper description, when seek share product pages via addthis.com extension, fb shows store logo instead of product images.
what do?
in theme header.tpl add:
<!-- mod og:image para fb --> <?php if ($thumb || $images) { ?> <meta property="og:image" content="<?php echo $thumb; ?>"> <?php } else { ?> <meta property="og:image" content="<?php echo $logo; ?>"> <?php } ?> <!-- mod og:image para fb -->
in controller/common/header.php, after: $this->data['name'] = $this->config->get('config_name'); add:
if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getproduct($product_id); $this->data['product_info'] = $product_info; if ($product_info['image']) { $this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')); } else { $this->data['thumb'] = ''; } $this->data['images'] = array();
php facebook share opencart
No comments:
Post a Comment