Post by oliwin » Thu Oct 26, 2017 6:42 am

I added image tag in HTML editor (HTML content module). I tried to set custom path like:

Code: Select all

But it replaces this on default path like:

Code: Select all

But there is not directory sites-images in project

New member


Tue Jan 10, 2017 2:00 am

Post by straightlight » Thu Oct 26, 2017 7:08 am

By viewing the view source interface of the default theme of Opencart on your browser, you can see the direct path of all images from every public page on your store. Another way would be by defining the image path from the relative controller that will output the template. An example would be like this, for instance:

Code: Select all


$data['my_image'] = $this->model_tool_image->resize($product_info['my_image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'));
This will load an image from the database which the field: my_image would need to exist but for this demonstration, you won't need it obviously.

From an actual image without relying on the database but directly on your file server, you could use:

Code: Select all

$data['my_image'] = DIR_IMAGE . 'my_image.ext';
Both case, in your related TWIG file, you could then use:

Code: Select all

{% if my_image %}
<img src="{{ my_image }}">
{% endif %}
The easiest way would be following the view source for each relative path but not the most simplified solution for merchants who uses multiple themes since each theme may use their own image path. However, that is not an obligation.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

Programmer / Opencart Tester

Legendary Member


Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 15 guests