5

Magento2 is looking directly in the root folder for media and static files. It is not looking in pub/media folder. Product images are not showing in the front. I installed Magento 2 in a subdirectory and with the installation.

I imported the products with Storemanager Emagicone, images were in import file (in root/media and pub/media because i did not know which to use),

Product images are in the front referring to a wrong path:

/media/catalog/product/cache/1/small_image/400x533/beff4985b56e3afdbeabfc89641a4582/y/o/yorkshire

When I look in FTP, the images are in pub/media/catalog/product. The above-mentioned directory is totally empty.

Moving the files from root/pub/media to root/media solved partially the problem. All basic images show up, but product images are not showing at all.

I already tried:php bin/magento setup:di:compile and php bin/magento setup:static-content:deployand php bin/magento cache:clean and php bin/magento indexer:reindex

The file permissions and user owner are OK, also i deleted all from ROOT > pub > static > EXCEPT .HTACCESS. I also deleted folder in: pub/static var/cache, var/view_preprocessed/css/frontend/ , ..source/frontend

I also looked in di.xml Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

No symlinks!

4
  • Did you manage to fix this. Please provide the answer.
    – stephen
    Nov 9 '16 at 10:57
  • 1
    Did you check your store configuration? I guess you didnt set your media path or even when, false. Dec 23 '16 at 20:22
  • Not sure if this is your problem, but the document root should point to <magento root>/pub.
    – Zsolti
    Mar 2 '20 at 20:17
  • can you try this module of magento 2 product images by customer Jun 2 at 11:59
8

For individual product, try saving the product in admin without any change.

For all products, try running the following command (this will take some time to complete):

php bin/magento catalog:images:resize
1
  • I am facing with error in Magento 2.3.4: Notice: Undefined index: keep_aspect_ratio in vendor/magento/module-media-storage/Service/ImageResize.php on line 308
    – huykon225
    Aug 7 '20 at 1:33
2

Please make sure to double check owner and group of pub/media directory.

You may run this command from magento root directory:

sudo chown www-data:www-data -R pub/media

Assuming www-data is used as Apache user.

Apache user should have permissions to a pub/media/catalog/product directory to create resized product image files.

Hope it helps.

1
  • Tried it but got Required file '/var/www/html/pub/media/catalog/product/watermark/ ' does not exists. Apr 16 at 5:34
2

1) Open di.xml from app\etc\di.xml

2) Search by Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink and use word Copy instead of Symlink so the final string will be

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

3) Save this file and remove everything from pub/static except .htacess

4) Through CMD. Clear your cache 5) Flush your cache 6) Do Reindexing

This time, images should be loaded.

0

I have tried everything but no luck. This article finally helped me fix issue

https://support.magento.com/hc/en-us/articles/115002446014-Product-images-are-not-displayed-although-set-on-the-Product-Edit-page

All you need to do is login to your db via phpMyAdmin (or similar), go to catalog_product_entity_varchar, search for records with value LIKE "no", you will find that few images may have no_selection as their value. Just remove all of those records.

Images should then display correctly

0

You may want to try: php bin/magento catalog:images:resize

If You're using watermarks, ensure those are also in place in pub/media/catalog/watermark/default

1
  • Sometimes running the Image Resize Function ensures that the Product Images are properly generated, and in some cases where watermarks are used, missing water6mark files will break the images being made.
    – J Harvey
    Jul 7 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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