5

I am having an issue with products images in Magento 2. The products were brought in from a Magento 1.7 install using the data migration tool. I then copied the media/catalog folder from the M1 install to the M2 install.

It appears that everything is working correctly: the product images show up in the Admin tool, and all of the products have thumbnails in the category listings. But when I click through to the product page, Magento 2 loads the default placeholder.

Even when I upload a new image and set it as the base, it does not appear on the product detail page.

I ran find ./pub/media -type d -exec chmod 777 {} \; and find ./pub/media/catalog -type f -exec chmod 777 {} \; to make sure it wasn't a permission issue, but I still can't get the product image to load.

I'm not sure how to debug this further, since it loads a placeholder I can't see what it is trying to load instead of the proper image.

Why isn't my product image loading?

  • Tried to run this command: php bin/magento catalog:images:resize? – Khoa TruongDinh Sep 19 '16 at 13:41
  • Have you checked firebug or similar for javascript errors in the product details page? This may also be an issue that stops your image from loading. – tecjam Sep 19 '16 at 13:54
5

We should run the catalog images command: php bin/magento catalog:images:resize.

Situations where this could be necessary might be:

  • After you import products, which might have images of various sizes
  • If images were resized or deleted manually from cache

Each image assigned to a product must be resized in accordance with image metadata defined in a module’s view.xml configuration file. After resizing an image, its resized copy is stored in the cache (/pub/media/catalog/product/cache directory). Magento serves storefront images from cache.

Source and more information here: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-images.html#resize-catalog-images

  • Ah, such an obvious solution, how did I overlook it? The script is running now, I will accept the answer when it completes and I can confirm that it solves my problem :) – andyjv Sep 19 '16 at 14:03
  • Do resized images get put in a certain folder? I ran catalog:images:resize for several hours– (before my computer went to sleep and closed the connection) –and I spot-checked a few products but I'm still getting the placeholder image. – andyjv Sep 20 '16 at 12:24
  • Is there any error log? – Khoa TruongDinh Sep 20 '16 at 12:27
  • Under pub/media/catalog/product/cache/1/image/265x265/[alphanumerics]/ I see images for products that I checked, but nothing else. There are no magento errors in the log, and doesn't appear to be any sever errors. – andyjv Sep 20 '16 at 12:36
  • Try to flush your Magento cache, not image cache pub/media/catalog/product/cache/. – Khoa TruongDinh Sep 20 '16 at 12:55
3

I believe I have it figured out. The way the image attributes were imported from Magento 1 confused me.

Screenshot of my product images tab: Magento 2 images attribute

Even though it looks like this product has an image in that first row, its actually the second row that matters. The first row is the gallery attribute, and the second is the image attribute.

Uploading an image to either attribute adds the image to both, which is why it was confusing. Disabling the "hidden" checkbox on the image in the second row fixed it.

  • 1
    Upvoted for you. – Khoa TruongDinh Sep 20 '16 at 14:34
  • Thank you so much for very important clue for this issue , upvoted for you Thanks :) – Manthan Dave May 8 '17 at 12:16
  • I am face issue in magento 2.2.2 , in my website all product have image but image is not display in product page if i am upload second image in product then only it will display on product view page. can u tell me how to display product image on product view page if product have only one image. – Sanjay Gohil Mar 9 '18 at 10:12
  • I am face issue in magento 2.2.5, in my website all product have image but image is not display in product page if i am upload second image in product then only it will display on product view page. can u tell me how to display product image on product view page if product have only one image – Magento2 Devloper Aug 15 '18 at 19:11
  • @Magento2Devloper you should probably create a new question for that – andyjv Aug 17 '18 at 12:08

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.