0

I'm using Magento 2.2.5 and when we visit listing or product page Magento creates the various sizes of images in pub/media/catalog/product/cache/ directory which I don't need except some.

I have checked file vendor/magento/framework/Config/etc/view.xsd but, nothing found related to stop/disable image generation.

As this creates lots of images and acquires disk spaces.

How to disable a particular type of image generation or anyone know the flow of image generation?

3
  • Did you find my answer useful? Feb 6, 2019 at 19:03
  • as @philipp said your answer has info of Magento's cache generation feature but not contain the answer which I'm looking. Do you know the core files which are used to create all type of images, or the flow of the generation of images?
    – Knight017
    Feb 7, 2019 at 4:14
  • I have found vendor/magento/module-catalog/Model/View/Asset/Image.php file returns the HASH path.
    – Knight017
    Feb 7, 2019 at 4:16

2 Answers 2

1

After debugging, we found that Magento internally calls various types of images in different files and they are generated.

We have implemented a workaround in the following way.

override all the image type and use the image dimensions which near the dimension we use in

app/design/frontend/Vendor/theme_01/etc/view.xml

and override the file which returns the image-file path hash according to misc-parameters like image's height, width, aspect ratio. We made it according to our requirement.

Magento\Catalog\Model\View\Asset\Image.php

As in our case, we need just a simple image and all other misc params are remain the same in all cases, we made return directory path like '100x90' as a directory name.

thus we get the 100x90 image in the pub/media/catalog/product/cache/100x90 directory

0

This is a feature of magento

When you upload image for product with specific image sizes, like 1200x1200 and you use it on thumbnail with the size 60x60 and small image like 200x200 and large image like 600x600. It creates cache images according to your given size.

The benefit of this is, user will not suffer in rendering large size images all over the website, it will show small image or thumbnail image on the web page, and that results with the high performance of the website.

Reference: What is the use of Magento 2.2.6 product image cache?

2
  • 2
    good explanation, but not an answer to the question Feb 6, 2019 at 14:14
  • The point is, this is a feature of magento and it can't be removed Feb 6, 2019 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.