Opencart 3.x Image src unknown error

Few days ago one of our client reported an error on his opencart store that was working perfectly in past. However suddenly it started giving error with the product images. He was not able to upload, edit, view images under admin panel as well as on front-end.

Images were failed to load on web site, and when i checked the source of images i found unknown or empty src. I tried to fix the errors while googling this issue but could not find any solution. Apparently i found out there is an image compressor php script included in the opencart. I just opened it at following location :

Front-end:

/home/username/public_html/catalog/model/tool/image.php

Admin Panel:

/home/username/public_html/admin/model/tool/image.php

While investigating i found script to compress images could not find image files or conditions returning false therefore it was terminating the script and returning empty url:

public function resize($filename, $width, $height) {
if (!is_file(DIR_IMAGE . $filename) || <strong>substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != str_replace('\\', '/', DIR_IMAGE)</strong>)
return;
}

In above condition, code in bold was causing the error that was returning empty url.

I just commented return statement and everything started to work normal.

To fix image uploading error, i also commented this condition in file:

/home/username/public_html/admin/controller/common/filemanager.php

 

This error is caused by the symbolic links of directories. If your host has different symbolic links than realpath then this issue will occur. We had this issue on our DirectAdmin server however on cPanel server this issue never occurred.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>