0

Newly uploaded images are not appearing on the Magento Front End when using Database as the media storage mechanism, in Magento CE 2.3.

I have tried almost everything, including cache clean, flush, resize images command.

One issue I've noticed is that the catalog:images:resize script returns an error complaining that File 'xyz.png' does not exist., which is correct, it does not exist - not on the filesystem at least, it's stored in the database (and I can see it in the database with the same directory).

Magento permissions are all fine. Hoping for some tips if anyone can help!

1 Answer 1

1

The reason you couldn't find your media images on the storeFront is Magento system couldn't transfer your media image file from the database to the file system. Yes though you saved your media file in the database , when the browser requests for the media file, Magento will fetch the binary file in the database and transfer it to the file system apparently to return it back to the browser. As your file is not in the file system which magento expects it doesnt show up and no surprise catalog:images:resize command failed eventually.

To be precise,there's a file under yourmagentoroot/pub/get.php which is the PHP script responsible to transfer the files from the database to the file system to fulfill browser media request. The possible reason that it couldn't be was it might not be triggered at all because of another rewrite configuration setting

So just set your debug break points in your editor for get.php and confirm whether it's triggered.

Besides these, also make sure you enabled mod-rewrite in your webserver (apache/nginx) and the file permissions are set right.

Before that get yourself acquainted with How Magento stores the media in the database and how it renders from their official 2.x (2.3) docs.

Hope am pointing you to the right direction.

System locates media in database. A PHP script transfers the files from the database to the file system, and sent to the customer’s browser. The browser request for media triggers the script to run as follows:

If web server rewrites are enabled for Magento and supported by the server, the PHP script runs only when the requested media is not found in the file system. If web server rewrites are disabled for Magento, or not supported by the server, the PHP script runs anyway, even if the required media is available in the file system.

5
  • Thanks! I checked the get.php file and tried to understand what's going on. One thing I noticed is that the derived 'mediaAbsPath' variable appears to contain the 'media' directory twice (I checked in the file system and it only appears once). Could this be a bug? ----- relativePath: media/catalog/product/cache/<hash>/m/o/model_1.jpg mediaDir: /var/www/html/pub/media/ mediaAbsPath: /var/www/html/pub/media//media/catalog/product/cache/<hash>/m/o/model_1.jpg
    – Scott
    Feb 4, 2019 at 13:46
  • I also verified, the get.php file is running as I was able to see echo output when accessing the image url. I can't understand why the image is not being downloaded from the DB.
    – Scott
    Feb 4, 2019 at 17:02
  • In get.php, just remove the media from the $relativePath variable and check. Certainly media absolute path shouldn't have media directory in its path variable twice, because as you can see there is no media directory inside pub/media. So this could solve your issue.
    – Haijerome
    Feb 5, 2019 at 5:52
  • Thanks - I tried but it still doesn't seem to work. It's as if the images just aren't being downloaded from the database even though they're in there.
    – Scott
    Feb 5, 2019 at 15:17
  • has anyone got a proper solution please let me know.I am also facing the same issue and can not regenrate the cache Apr 11, 2019 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.