cancel
Showing results for 
Search instead for 
Did you mean: 

Newly added product images are not displayed after Magento Upgrade

Newly added product images are not displayed after Magento Upgrade

I upgraded Magento 2.4.3-p3 / PHP 7.4.33 to Magento 2.4.5-p2 / PHP 8.1.19. For an existing product, I uploaded a new image via Admin backend. At the file system, I can see the relevant image file, and the corresponding generated cached image files:

 

-rw-rw-r-- 1 mageuser magegroup 4032 Jun 12 14:27 ./media/catalog/product/cache/a2c5e6752d7ee5266fa74a630c574e07/m/y/myluma.jpg
-rw-rw-r-- 1 mageuser magegroup 4032 Jun 12 14:27 ./media/catalog/product/cache/53228d222ee84f59f8efef180876821c/m/y/myluma.jpg
-rw-rw-r-- 1 mageuser magegroup 2434 Jun 12 14:27 ./media/catalog/product/cache/090f5b466d299a2ad8b70d0e20f02fcb/m/y/myluma.jpg
-rw-rw-r-- 1 mageuser magegroup 2434 Jun 12 16:04 ./media/catalog/product/cache/b25cdd12b78cad01dcb1b59f431934c5/m/y/myluma.jpg
-rw-rw-r-- 1 mageuser magegroup 94510 Jun 12 19:01 ./media/catalog/product/cache/4d924e7a364452af5cb4e59f1d428da8/m/y/myluma.jpg
-rw-rw-r-- 1 mageuser magegroup 4032 Jun 12 14:27 ./media/catalog/product/cache/df92d7fb11dfae7100ba4201904e7e43/m/y/myluma.jpg
-rw-rw-r-- 1 mageuser magegroup 4032 Jun 12 14:27 ./media/catalog/product/cache/1d3f7a146db4fca3baf6bb3312454dcb/m/y/myluma.jpg
-rwxrwxr-x 1 mageuser magegroup 179998 Jun 12 14:27 ./media/catalog/product/m/y/myluma.jpg

At the product page, I can see the newly added image at the bottom, but when I select it, the placeholder is shown instead of the image. This happens only with the product images added after the upgrade; the images that had been added before Magento upgrade are normally displayed on the product page.

 

6 REPLIES 6

Re: Newly added product images are not displayed after Magento Upgrade

At the product page, I can see the newly added image at the bottom, but when I select it, the placeholder is shown instead of the image. This happens only with the product images added after the upgrade; the images that had been added before Magento upgrade are normally displayed on the product page.

 

Screenshot 2023-06-13 090212.png

Re: Newly added product images are not displayed after Magento Upgrade

Hello @dandrikop 

 

  1. In the Magento Admin, navigate to System > Tools > Cache Management and flush all caches. This will ensure that any outdated cache related to product images is cleared.

  2. Ensure that the file permissions for the newly uploaded images and their corresponding cached images are correctly set. The web server should have sufficient permissions to read and serve these image files. Typically, the file permissions should be set to 644 for files and 755 for directories. You can use the chmod command to adjust file permissions if needed.

  3. Sometimes, cached images can become corrupted during the upgrade process. To regenerate the image cache, you can delete the contents of the media/catalog/product/cache directory. This will prompt Magento to regenerate the cached images when they are accessed. Make sure to back up the contents of the directory before deleting them.

  4. Check the configuration settings for the base media URL and the product image path in the Magento Admin. Ensure that the paths are correctly set and pointing to the appropriate locations where the images are stored.

  5. After upgrading Magento, it's essential to reindex the data. In the Magento Admin, go to System > Tools > Index Management and reindex all relevant indexes. This can help ensure that the product images are properly indexed and linked.

  6. Review the Magento logs for any relevant error messages or warnings that could provide further insights into the issue. Look for any image-related errors or exceptions that might be logged.

Was my answer helpful? You can accept it as a solution.
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer

Re: Newly added product images are not displayed after Magento Upgrade

I have checked all the points you have mentioned and everything was as expected. The caches were refreshed many times. Moreover, I indicated in this post that the permissions were 664. Also, the resizing process works fine as soon as I upload a new product picture since appropriate image files are generated under the directory media/catalog/product/cache.

 

In my opinion, Magento should somehow provide an invalid URL for the corresponding cached image, so the front-end ends up with the placeholder image. Something which could be helpful for debugging purposes may be to find what is that invalid URL for the corresponding cached image.

Re: Newly added product images are not displayed after Magento Upgrade

  1. Clear Cache: System > Tools > Cache Management > Flush all caches.
  2. Set File Permissions: Ensure 644 for files and 755 for directories.
  3. Regenerate Cached Images: Delete media/catalog/product/cache contents.
  4. Check Configuration: Verify base media URL and image path settings.
  5. Reindex Data: System > Tools > Index Management > Reindex.
  6. Review Logs: Check for image-related errors or warning

Re: Newly added product images are not displayed after Magento Upgrade

this worked for me

 

Git Commit 

Re: Newly added product images are not displayed after Magento Upgrade



Please check this file

pub/media/.htaccess

 is exits or not? if not please try to undo this.

Run this commend:

git checkout pub/media/.htaccess

in may case it was deleted.

Now images are showing...