Magento – Product images returning 404 after updating Magento 2

404mediamedia-imagesproduct-images

I just updated Magento 2 CE from 2.0.7 to 2.1.5. I used the terminal method and all seems well. Everything is working and the new version is reflected in the bottom of the admin section. Only problem I'm having is that the product images now return a 404.

An example path that use to work but is now 404:
https://example.com/media/catalog/product/i/p/iphone6s_family_280x420.png

What does actually work:
https://example.com/pub/media/catalog/product/i/p/iphone6s_family_280x420.png

How can I correct this? Thanks.

Best Answer

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
find ./pub/media -type d -exec chmod 777 {} \;

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.

Related Topic