Websterz Technology Blog

Free tutorials, Tech News, Source codes, Tweaks and Tips.

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 :



Admin Panel:


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) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != str_replace('\\', '/', DIR_IMAGE))

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:



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.

Spread the love
See also  How to deal with hackers for web server? Sym links solution

Leave a Reply

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