Hi!
Figured it out by myself, and want to share if anyone else need this functionality.
This extension adds functionality to have a custom OpenGraph Image for products. If not present, it will use the main image.
This is made for OpenCart 2.2.0.0. Please feel free to comment with suggestions.
I have attached my VQMod-file.
You must add a column to the product table in the database:
Code: Select all
ALTER TABLE `oc_product` ADD `ogimage` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `image`;
To use this mod you also need VQMod installed and this extension:
http://www.opencart.com/index.php?route ... n_id=22963
In the
OpenGraph-extension modify the following:
Code: Select all
if ($product_info['image']) {
$this->document->addOGMeta('property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($product_info['image'], 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
} else {
$this->document->addOGMeta( 'property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($this->config->get('config_logo'), 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
}
foreach ($results as $result) {
$this->document->addOGMeta( 'property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($result['image'], 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
}
to this:
Code: Select all
if ($product_info['ogimage']) {
$this->document->addOGMeta('property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($product_info['ogimage'], 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
} else if ($product_info['image']) {
$this->document->addOGMeta('property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($product_info['image'], 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
} else {
$this->document->addOGMeta( 'property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($this->config->get('config_logo'), 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
}
foreach ($results as $result) {
$this->document->addOGMeta( 'property="og:image"', str_replace(' ', '%20', $this->config->get('config_url') . $this->model_tool_image->resize($result['image'], 1200, 630)) );
$this->document->addOGMeta('property="og:image:width"', '1200');
$this->document->addOGMeta('property="og:image:height"', '630');
}