The best solution is to change the ownership of /media/ folder.
Change the permission to 777.
You can choose not to convert some specific images, too.
You can do it by executing the code snippet below.
Best Solutions To Fix Magento 2 Images Not Showing Issue
- Case 1: Image doesn’t display in front-end but displays in admin
- Case 2: Image doesn’t display in admin
Image doesn’t display in front-end but displays in admin
Reason 1: You have mistaken permissions in your /media/ folder.
Let’s go!
Mostly, it happens due to wrong permissions set to uploaded files.
If you are facing the problem that your images don’t display on your Magento 2 website, then you are at the right place.
There are some reasons that cause the issue to occur. And below, we will check all the points in depth.
Table of Contents
The solution for this is to increase your PHP memory limit.
And to do it, it is recommended to use the WebP format to optimize the image size. WebP format can maintain the image’s quality but compress it to be around 30% smaller.
Reason 3: Low PHP memory limit.
We hope this blog is helpful and good luck to you!
php_value memory_limit 256M
Writing is a part of my life and I’m living for it.
Highlight features:
The solution is to check with the hosting provider as they have installed the GD library on the server.
Reason 4: The GD library is not installed or configured.
BSS Commerce is one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bringing high-quality products and services to optimize your business effectively. Furthermore, we offer FREE Installation – FREE 1-year Support and FREE Lifetime Update for every Magento extension.
Image doesn’t display in admin
chown -R {username}:{username} media/
In this article, we will help you solve the problem of Magento 2 images not showing in just some simple steps.
if (!(@is_dir($destinationFolder) || @mkdir($destinationFolder, 0777, true))) {
The Best Solution To Optimize Your Images
And the size of your images is a noteworthy aspect. It affects the website design, SEO and conversion rates.
chmod -R 777 media/
Reason 2: Media folder is owned by another owner.
There can be two cases of the problem:
In this article, we have pointed out some reasons that lead to the issue of Magento 2 images not showing and how to fix them.
It also allows you to choose to change the image format on some specific page. For example, you can choose to convert images on the home page, product page, category page, or CMS page.
Due to the low memory limit, Magento 2 cannot resize your images and will display placeholder images.
CONTACT NOW to let us know your problems. We are willing to support you every time.
Thus, you should keep all images on a single page to a total of 1 MB or less.
Around line 219:
To fix it, open lib/Varien/File/Uploader.php.
This extension allows you to convert all product images on your website to the WebP format with only a few clicks.
You can do this using SSH through this command.
- Automatically convert images under other formats (e.g., jpg, png, jpeg) to Webp to optimize the loading and display speed of your website.
- Choose specific places you want to convert your images to WebP format: All, Product Page, Category Page, Home Page, CMS Page.
- Reduce time spent on conversion, automate every media upload, and deliver better-looking images.
Conclusion
The solution regarding this point is that please check whether writable permission is given on this folder or not.
Check if the permission is set or not.
PHP memory limit plays an important role in resizing images in Magento 2.
chmod($destinationFile, 0666);
Magento 2 Convert Images to WebP by BSS