Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to image urls and default image #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ Adds the open graph meta tags to your Prestashop site. Open graph meta tags allo
3. Rename folder to jk_opengraph.
4. ZIP jk_opengraph folder.
5. Install it through prestashop back office.

# Configuration

1. Upload image at least for Index page - if no other provided, image will be used for other pages but product detail(product cover image is used here)
2. If no image is uploaded, module uses eshop logo as default image
3. Use "turn off tags" for product tags if your template has default OG tags on product detail page(classic theme has them now, not sure from which version)
12 changes: 7 additions & 5 deletions classes/TagsRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function addAdditionalTags($tags)
$product = new Product($id_product, true);
if ($this->page->type == OpengraphPage::TYPE_META_TAGS) {
$id_cover = Product::getCover($id_product);
$id_cover['id_image'] ? $tags['image'] = Context::getContext()->link->getImageLink($id_product, $id_cover['id_image']) : '';
$id_cover['id_image'] ? $tags['image'] = Context::getContext()->link->getImageLink($product->link_rewrite[Context::getContext()->language->id], $id_cover['id_image'], ImageType::getFormatedName('large')) : '';
}
$tags['product'] = array(
'brand' => Manufacturer::getNameById((int)$product->id_manufacturer),
Expand All @@ -122,15 +122,17 @@ private function addAdditionalTags($tags)
public function getImageUrl()
{
$index = new OpenGraphPage(1);

if ($this->page->type == OpengraphPage::TYPE_INDEX_TAGS && $index->image != '') {
$url = Media::getMediaPath(_PS_MODULE_DIR_ . 'jk_opengraph/views/img/' . $index->image); //index image
} elseif ($this->page->image != '') {

if ($this->page->image != '') {
$url = Media::getMediaPath(_PS_MODULE_DIR_ . 'jk_opengraph/views/img/' . $this->page->image); //individual image
} elseif ($index->image) {
$url = Media::getMediaPath(_PS_MODULE_DIR_ . 'jk_opengraph/views/img/' . $index->image); //index image
} else {
$url = _PS_IMG_ . Configuration::get('PS_LOGO'); // shop logo
}

$url = _PS_BASE_URL_ . $url; //add base url

return $url;
}
}
4 changes: 2 additions & 2 deletions jk_opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct()
{
$this->name = 'jk_opengraph';
$this->tab = 'front_office_features';
$this->version = '1.3.2';
$this->version = '1.3.3';
$this->author = 'yusttas.github.io';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
Expand All @@ -76,7 +76,7 @@ public function install()
}

if (!parent::install() //Check that the module parent class is installed.
|| !$this->registerHook('header')
|| !$this->registerHook('displayHeader')
|| !$this->installTables()
|| !$this->installPages()
|| !$this->installConfig()
Expand Down
2 changes: 1 addition & 1 deletion views/templates/hook/opengraph.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta property="og:url" content="{$urls.current_url}">
<meta property="og:title" content="{$tags.title}">
<meta property="og:description" content="{$tags.description}">
<meta property="og:image" content="{$urls.shop_domain_url}{$tags.image}">
<meta property="og:image" content="{$tags.image}">
<meta property="og:image:alt" content="{$tags.site_name} - {$tags.title}">
{if $tags.site_type=='product'}
{if $tags.product.brand}
Expand Down