cancel
Showing results for 
Search instead for 
Did you mean: 

Images not showing when Database Media Storage is used

Images not showing when Database Media Storage is used

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).

 

Not sure if it's relevant, but I see this error mentioned in the logs: Cannot gather stats! Warning!stat(): stat failed for

 

Magento permissions are all fine and rewrites are enabled (verified by checking that get.php is called). Hoping for some tips if anyone can help!

5 REPLIES 5

Re: Images not showing when Database Media Storage is used

I did some more investigation and it seems to be an issue with saving of the image once the product is saved.

 

I see the below errors in the exception.log which reference the newly uploaded image:

 

[2019-02-05 15:30:19] main.CRITICAL: Cannot resize image "/var/www/html/pub/media/catalog/product/n/e/newmodel.png" - original image not found {"exception":"[object] (Magento\\Framework\\Exception\\NotFoundException(code: 0): Cannot resize image \"/var/www/html/pub/media/catalog/product/n/e/newmodel.png\" - original image not found at /var/www/html/vendor/magento/module-media-storage/Service/ImageResize.php:136)"} []
[2019-02-05 15:30:20] main.WARNING: Cannot gather stats! Warning!stat(): stat failed for /var/www/html/pub/media/catalog/product/n/e/newmodel.png {"exception":"[object] (Magento\\Framework\\Exception\\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /var/www/html/pub/media/catalog/product/n/e/newmodel.png at /var/www/html/vendor/magento/framework/Filesystem/Driver/File.php:72)"} []

 

 

I can see the new row in the 'media_storage_file_storage' table in the database, but for some reason Magento is not able to pull the image.

 

When I initially uploaded the image, it was accessible from '/pub/media/tmp/catalog/product/n/e/newmodel.png' temporarily, but this got deleted as soon as I saved the product. I expect one this happens, the file is supposed to get moved to the cache instead, which doesn't seem to be happening.

 

Any help would be greatly appreciated!

Re: Images not showing when Database Media Storage is used

Were you able to figure this out?

Re: Images not showing when Database Media Storage is used

same problem with image import and same error, images are not written in into the cache storage. After searching the forum extensively the only solution it seems is to revert to backup

Re: Images not showing when Database Media Storage is used

Anyone found the solution yet?

 

Those who having this issue using Magento 2.3.1? or switched from developer to production mode?

Re: Images not showing when Database Media Storage is used

New guy here,

 

I am helping transition from M1 to M2, but came across this message as I don't have a media_storage_file_storage table at all!

 

However, I have been stepping through the code trying to make my images appear.

 

I found the pub/get.php was failing on 'cached' files as the code:

 
$transfer = new \Magento\Framework\File\Transfer\Adapter\Http(
                    new \Magento\Framework\HTTP\PhpEnvironment\Response(),
                    new \Magento\Framework\File\Mime()
                );

failed as the function getInstance() in vendor/magento/framework/App/ObjectManager.php

exceptioned on 

if (!self::$_instance instanceof \Magento\Framework\ObjectManagerInterface) {
            throw new \RuntimeException('ObjectManager isn\'t initialized');
        }

The ObjectManager had not been set.

 

I moved (in get.php)

$params = $_SERVER;
if (empty($mediaDirectory)) {
    $params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = [];
    $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]];
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
 

higher in the code before the cache check and the ObjectManager was thus initiali(s|z)ed.

 

At this point (having got past that hurdle) it came to the part checking for the database table.

 

Now back to your issue, could it be that something is causing an exception and the transaction of uploading the image to being cached is failing?