Answer the question
In order to leave comments, you need to log in
How to automatically detect image url on OpenCart page?
Hey!
Have a tag
<meta property="og:image" content="https://www....///...///.. .jpg" />
on all pages of the OpenCart 3.0 site {% if og_image %}
<meta property="og:image" content="{{ og_image }}" />
{% else %}
<meta property="og:image" content="{{ logo }}" />
{% endif %}
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
$this->load->language('common/header');
$host = isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1')) ? HTTPS_SERVER : HTTP_SERVER;
if ($this->request->server['REQUEST_URI'] == '/') {
$data['og_url'] = $this->url->link('common/home');
} else {
$data['og_url'] = $host . substr($this->request->server['REQUEST_URI'], 1, (strlen($this->request->server['REQUEST_URI'])-1));
}
$data['og_image'] = $this->document->getOgImage();
</head>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question