Magento Tutorials

Magento images not showing up in admin or in frontend

If you are using Magento platform for your e-commerce website, sooner or later you definitely may encounter the not showing image issue.

But don’t you worry. If you know the reason, you will handle this issue easily.

1. Image is visible in Magento admin backend, but not visible in customer frontend

Possible reason 1: You have wrong permissions on your /media/ folder

Solution: Ensure you have writable permissions on this folder. Change permissions to 777 recursively. You can do it using SSH via this command (execute it in Magento directory):

> chmod -R 777 media/

Possible reason 2: Media folder is owned by another user.

This can happen if you transfer your Magento store from one server to another.

Solution: Change ownership of the /media/ folder:

> chown -R {username}:{username} media/

Important: Make sure that folder owner is the same user as your web server user. If you are not sure, contact your server support administrator.

Possible reason 3: There’s an issue with the .htaccess file in your /media/ folder

Solution: Go to your media folder and rename the original .htaccess file, or execute the following command in Linux:

cd /media/
mv .htaccess .htaccess1

Possible reason 4: Magento cannot resize images due low PHP memory limit.

Magento resize images using GD library, however if there is no sufficient amount of memory for such operation Magento will return a placeholder image.

Solution: Increase your memory limit. You should open your .htaccess file and find this string:

php_value memory_limit 256M

Make sure that this value is at least 256M, or better 512M.

Possible reason 5:The GD library is not installed/configured

Solution: Make sure that your hosting installed GD library on your server, you can check it using php info.

Possible reason 6:Wrong attribute scope for small_image, thumbnail, base_image

Sometimes Magento processes images incorrectly, if they have scope=Store View (especially in case of multi-store installation)

Solution: You should open your Magento backend > Catalog > Attributes > Manage attributes. After this you should find image, small_image & thumbnail attributes. Make sure that all these attributes have scope = Global.

Possible reason 7: no_selection values for image, small_image, thumbnail, swatch

Product images do not display despite Product Edit image roles is an official bug caused by improper synchronization between a particular store and the Global store settings.

Solution: delete attributes with no_selection values using this SQL script:

DELETE `cpev_s`.* FROM `catalog_product_entity_varchar` `cpev_s` JOIN `eav_attribute` `ea` ON `cpev_s`.`attribute_id` = `ea`.`attribute_id` LEFT JOIN `catalog_product_entity_varchar` `cpev_0` ON `cpev_0`.`row_id` = `cpev_s`.`row_id` AND `cpev_0`.`attribute_id` = `cpev_s`.`attribute_id` AND `cpev_0`.`store_id` = 0 WHERE `cpev_s`.`value` = 'no_selection' AND `ea`.`attribute_code` IN ('image', 'small_image', 'thumbnail') AND `cpev_s`.`store_id` > 0 AND `cpev_s`.`value` != `cpev_0`.`value` AND `cpev_s`.`value` = 'no_selection';

Possible reason 8: Problem with safe mode

Solution: It is not recommended to disable safe mode, but if you tried all other solutions you might try to disable safe mode on your server

Possible reason 9: Out of date static content

Solution: Regenerate your static content by running the following command:

php bin/magento setup:static-content:deploy -f <locale>

To find your <locale> code, run: php bin/magento info:language:list, and choose from the list a locale code for your store.

For example, here’s our command for the English – United State locale:

php bin/magento setup:static-content:deploy -f en_US

2. Images is not displaying in Magento backend

This can be caused by wrong permissions set to uploaded files. Open lib/Varien/File/Uploader.php and make sure following permission are set:

Around line 219:

chmod($destinationFile, 0666);

Around line 541:

if (!(@is_dir($destinationFolder) || @mkdir($destinationFolder, 0777, true))) {

Note: This issue can also be fixed by applying patch SUPEE-7405 v1.1.

Hope this helps!


Further Reading:

A Beginner Guide To Magento 2 File Permissions

How to Configure Image Sizes in Magento

Upload Images for Configurable Swatches in Magento

How to Resize Images in Magento 1 & 2

Dom

A knowledge craver who always strive to be wiser everyday.

Subscribe
Notify of
guest

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
gh darvishani
2 years ago

thanks
this post saved my day

Jason R
Jason R
2 years ago

In my case it was because elastic search wasn’t setup/working properly, which was due to insufficient server RAM. Caused the search bar results to crash the site and a side effect was also that all the product images were 0 bytes in the backend and not visible on the frontend. Problem is they are still 0 bytes after the fix, but at least we can re-upload images now.