There is a file
vendor/magento/theme-frontend-luma/etc/view.xml that you may want to understand.
This file will also be duplicated in your theme.
It has quite a lot of entries as you can see. Each setting will create a different file. Also, luma theme extends blank theme and I suspect the
view.xml file from blank is also merged to this luma view file.
Overall, there are 30 image settings in these files. I made some experiments today.
- loading a category page with 1 product
- visiting the product detail page
- adding the product to the cart
What seems to happen is: the category page triggers the images for the product in the category to be generated for all these view settings.
More accurately, the code
\Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Image::collect is triggered when we load the category page
If you want to reduce the size of this folder, I suggest 2 things:
- If there is a setting you don't use, then change the view settings to be minimal in image size will mean the generated image in the cache folder will be smaller.. With your catalog, it will likely make a difference. This is a workaround rather than a solution of course
- The real solution would consist in removing some of these settings as it is likely you are not using them all. To do this, i have some ideas but they are yet to be implemented.
the most straightforward would be to write an after plugin on the function
\Magento\Framework\Config\View::getMediaAttributes to limit the settings to interact with.