Skip to main content
17 votes
Accepted

How to delete unused images from my media folder?

You can use the Hackathon EAV cleaner module for this. After installation you can use the command eav:media:remove-unused You can find it on Github: https://github.com/magento-hackathon/EAVCleaner/...
Tjitse's user avatar
  • 1,310
13 votes
Accepted

how to save image custom attribute in magento 2

In your observer there is a lot of unnecessary code. You can change it like: <?php namespace Dcw\Vm\Observer; use Magento\Framework\Event\ObserverInterface; class ProductSaveAfter implements ...
Siarhey Uchukhlebau's user avatar
11 votes

Hide small images on frontend Magento 2

You can try with either CODE or CSS 1) Changing / Adding code in your extended view.xml Can find at below path or if not present then you can create app/design/frontend/vendor-name/theme-name/...
Manoj Deswal's user avatar
  • 5,805
8 votes

Hide small images on frontend Magento 2

In admin panel product level, when you are uploading the image and setting role as small in the same time choose Hide from Product Page checkbox as well. then flush the cache and see result you will ...
Kanhaiya lal's user avatar
  • 1,548
6 votes
Accepted

Magento 2 : how to include custom image in email template?

You can upload images at the module level or theme level inside the web/images folder and use the below code inside the email template for getting these images. <img src="{{view url='...
Amit Saini's user avatar
5 votes

how to save image custom attribute in magento 2

Retrieving in frontend: Let's say that the product for which you want to display the virtual mirror is $product. You can get the images that are marked with your custom attribute like this: $...
Marius's user avatar
  • 198k
5 votes

Clean way to add media gallery images to product collection

If you look at the \Magento\Catalog\Model\ResourceModel\Product\Collection class there is actually a method addMediaGalleryData that will add the media gallery data to the product collection. /** @...
drew7721's user avatar
  • 848
5 votes

Magento2 Add Media Gallery data in product collection

I know this is an old question, but Magento 2 has changed a bit and an easier way (imho) is using the addMediaGalleryData() method of the Magento\Catalog\Model\ResourceModel\Product\Collectionclass. ...
simonthesorcerer's user avatar
5 votes

What is the use of the view.xml of theme etc directory

In this file you can configure some properties related with FE. E.g size of the images of prodcuts on the overview list. You can also add here a custom ID of image with your own size and generate ...
K. Maliszewski's user avatar
5 votes

Images with size larger than 1 MB give error - Magento 2.3

To resolve this issue Create a file in your pub directory phpinfo.php and add this code in it: Execute this file from your browser www.yourwebsite.com/phpinfo.php If you are getting 404 error, then ...
Shoaib Munir's user avatar
  • 9,522
4 votes

Browse button is missing from media storage

Open up the following file:- lib/Varien/File/Uploader.php Look for this line:- chmod($destinationFile, 0640); Replace it with this line:- chmod($destinationFile, 0644); Look for this line:-...
Learing_Coder's user avatar
4 votes
Accepted

Cache issue (Images not loading)

There are many things that could be causing this issue, Please look into few things: Make sure the product images exist under /media/catalog/product/ (relative to your document root) On the Product ...
Shubham Khandelwal's user avatar
4 votes
Accepted

Can't get media image in the phtml file

In your Block file add: public function __construct( ... \Magento\Store\Model\StoreManagerInterface $storeManager, ... ) { $this->storeManager = $storeManager; ...
Amrit Pal Singh's user avatar
4 votes
Accepted

Media images not showing in custom module

I had the same issue and it is fixed. I saw the image has data-amsrc attribute. it is added by amasty "Google Page Speed Optimizer" module. There is config in admin to ignore images contain ...
Wenping Guo's user avatar
4 votes
Accepted

Cannot create new folder under Storage Root - Magento Media Gallery

Since Magento 2.4.3-p1, for security purposes Magento only allows the media gallery access to the following two directories under /pub/media: catalog/category wysiwyg In versions 2.4.3-p1 and higher,...
Tu Van's user avatar
  • 7,423
3 votes
Accepted

Need to Update Product Media Gallery Image Label

Try below code. <?php Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $product_id = 142; //Your Product Id $product = Mage::getModel('catalog/product')->load($...
Dinesh Yadav's user avatar
  • 6,465
3 votes

Cant access images in /pub/media/customer

Just remove .htaccess from pub/media/customer and image start loading at front-end.
Vish Vaghela's user avatar
3 votes

magento image filename auto renaming

By default Magento added this check as if same file exist then rename it because there may be possibility admin can upload different image with same name. So as your requirement you need to do some ...
Akhil Gupta's user avatar
  • 1,946
3 votes

How to delete unused images from my media folder?

The easier method that I found is installing the module below and running these commands. composer require ekouk/imagecleaner "dev-master" bin/magento setup:upgrade bin/magento setup:di:...
Rafael Corrêa Gomes's user avatar
3 votes

Can I delete media directories left over from an unused non-composer installed module in Magento 2?

If you're sure they're not used then Yes. However if you're still an it nervous use this command mv media/magefan_blog/ /home/#user#/magefan_blog/ Obviously replace ##user## with your user or ...
Timothy Frew's user avatar
3 votes
Accepted

Magento 1 - Storing media files in the database

Magento has explained this in their doc: http://docs.magento.com/m1/ce/user_guide/system-operations/media-storage-database.html The only thing I have noticed is that, magento will need to run a php ...
Nidheesh's user avatar
  • 1,048
3 votes
Accepted

Use API rest media management by storeView code (admin)

Use the all keyword in your API call if you want your value to affect all stores. rest/all/V1/products/{sku}/media Review Magento's documentation regarding this below. http://devdocs.magento.com/...
Mat Hellums's user avatar
3 votes

Magento2 Add Media Gallery data in product collection

Make sure to add addMediaGalleryData() after you've set all filter of your collection, because else it won't take them into account.
Ovidiu Caramida's user avatar
3 votes
Accepted

Unable to get Product custom image role in magento 2

I have faced the same issue if you have created attribute same way as @AliHussain mention then you have to just need to change one thing in attribute management using inspect element change the value ...
Rakesh Varma's user avatar
  • 2,226
3 votes
Accepted

Custom Attribute for Product Image Not Showing Saved Values in Admin Form (Media Gallery Attribute)

Here is my example module from mentioned question/answer on GitHub. You can examine a commit https://github.com/SiarheyUchukhlebau/Dcw_Vm/commit/baf4053dc1d9fa625122cddcfb0da05029bda41f to detect, how ...
Siarhey Uchukhlebau's user avatar
3 votes
Accepted

The images show on frontend pagespeed.ic._LOWhFVaw2.webp after image filename

The images are being automatically optimised by the pagespeed module The PageSpeed Modules, mod_pagespeed and ngx_pagespeed, are open-source webserver modules that optimize your site automatically. ...
paj's user avatar
  • 5,924
2 votes
Accepted

How do you link images set as backgrounds in your CSS file?

The proper way to reference the images would be using Unix-style directory symbols: ../images/your-image.png. Ideally, you'd put styles like this in the HTML head or perhaps inline them. Either way, ...
tjons's user avatar
  • 1,831
2 votes

Product images returning 404 after updating Magento 2

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 -...
gelanivishal's user avatar
  • 1,336
2 votes
Accepted

products gallery not export in magento 1.9.1.0

Its version issue: Check these two files you will get answer: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php This code is ...
Sharfaraz Bheda's user avatar
2 votes

Browse button is missing from media storage

Common issue with Magento 1.x (prior to 1.9.3), main cause is the old flash buttons (yes flash buttons) which were replaced with css buttons so if using older version ensure that files uploader.swf ...
Devtype's user avatar
  • 3,008

Only top scored, non community-wiki answers of a minimum length are eligible