PHPackages                             blackbird/magento-2-clean-product-image-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. blackbird/magento-2-clean-product-image-cache

ActiveMagento2-module

blackbird/magento-2-clean-product-image-cache
=============================================

Clean product images cache file in Magento 2. Usefull if image name doesn't change

1.0.4(4mo ago)310.9k↓27.6%11MITPHP

Since Nov 17Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/blackbird-agency/magento-2-clean-product-image-cache)[ Packagist](https://packagist.org/packages/blackbird/magento-2-clean-product-image-cache)[ RSS](/packages/blackbird-magento-2-clean-product-image-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (6)Used By (1)

magento-2-clean-product-image-cache
===================================

[](#magento-2-clean-product-image-cache)

[![Latest Stable Version](https://camo.githubusercontent.com/4f7e0d0b2eb3de8c977c19f21c7250bee9dcbaef07d742736035565ed3a1f2e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d626c7565)](https://packagist.org/packages/blackbird/magento-2-clean-product-image-cache)[![License: MIT](https://camo.githubusercontent.com/1737f52ec1591c3799c179972a82ec76fd50bce34cf135a4c23c51b36fa40819/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f626c61636b626972642d6167656e63792f6d6167656e746f2d322d636c65616e2d70726f647563742d696d6167652d63616368652e737667)](./LICENSE)

Sometimes you want to change product image without changing image name for many reason.

**Problem** : if changed images was already generated in `pub/media/catalog/product/cache/` folders you need to delete all generated cached images to have your new image in front and in cache.

**Solution** : this module which clean product image generated cache on product save.

[How It Works](#how-it-works) • [Installation](#installation) • [Add your own clean cache strategy](#add-your-own-clean-cache-strategy) • [Support](#support) • [Contact](#contact) • [License](#license)

How It Works
------------

[](#how-it-works)

When you save a product in the back-office it will delete all generated image cache file from the saved product in `pub/media/catalog/product/cache/*`

Installation
------------

[](#installation)

```
composer require blackbird/magento-2-clean-product-image-cache

```

```
php bin/magento setup:upgrade

```

*In production mode, do not forget to recompile and redeploy the static resources.*

Add your own clean cache strategy
---------------------------------

[](#add-your-own-clean-cache-strategy)

If you use a CDN like Cloudflare, you maybe need to use her API to clean the CDN cache. We give you two way to do that :

- create your own strategy class
- create your observer on our event `blackbird_image_cache_clean_after`

**If you are using Cloudflare** we have an extension of this module which call Cloudflare API to purge cache : [blackbird/magento-2-clean-cloudflare-image-cache](https://github.com/blackbird-agency/magento-2-clean-cloudflare-image-cache)

### Create your own strategy :

[](#create-your-own-strategy-)

#### Create your own strategy service implementing `Blackbird\CleanProductImageCache\Api\CleanCacheStrategyInterface`

[](#create-your-own-strategy-service-implementing-blackbirdcleanproductimagecacheapicleancachestrategyinterface)

```
class MyCleanCacheStrategy implements CleanCacheStrategyInterface
{
     /**
     * {@inheritDoc}
     */
    public function clean(ProductInterface $product): void
    {
        //Do what you need to do
    }
}
```

#### Add you strategy to the pool in your `di.xml`

[](#add-you-strategy-to-the-pool-in-your-dixml)

```
...

                    Vendor\Module\Model\Service\MyCleanCacheStrategy
                    10
                    true

...
```

You can use sortOrder and enabled to change execution order or disable strategies.

### Use the dispatched event :

[](#use-the-dispatched-event-)

#### Create your Observer :

[](#create-your-observer-)

```
class AfterCleanMagentoImageCache implements ObserverInterface
{
     /**
     * {@inheritDoc}
     */
    public function execute(Observer $observer): void
    {
        //Get absolute path off all cached images for the cleaned product
        $paths = $observer->getPaths();
        //Do what you need to do
    }
}
```

#### Plug it your Observer in the events.xml :

[](#plug-it-your-observer-in-the-eventsxml-)

```
...

...
```

Support
-------

[](#support)

- If you have any issue with this code, feel free to [open an issue](https://github.com/blackbird-agency/magento-2-clean-product-image-cache/issues/new).
- If you want to contribute to this project, feel free to [create a pull request](https://github.com/blackbird-agency/magento-2-clean-product-image-cache/compare).

Contact
-------

[](#contact)

For further information, contact us:

- by email:
- or by form: [https://black.bird.eu/en/contacts/](https://black.bird.eu/contacts/)

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

***That's all folks !***

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance76

Regular maintenance activity

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~196 days

Total

5

Last Release

129d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12445118?v=4)[anthony-blackbird](/maintainers/anthony-blackbird)[@anthony-blackbird](https://github.com/anthony-blackbird)

---

Top Contributors

[![kevin-blackbird](https://avatars.githubusercontent.com/u/37531549?v=4)](https://github.com/kevin-blackbird "kevin-blackbird (5 commits)")[![cpblackbird](https://avatars.githubusercontent.com/u/62594672?v=4)](https://github.com/cpblackbird "cpblackbird (1 commits)")

### Embed Badge

![Health badge](/badges/blackbird-magento-2-clean-product-image-cache/health.svg)

```
[![Health](https://phpackages.com/badges/blackbird-magento-2-clean-product-image-cache/health.svg)](https://phpackages.com/packages/blackbird-magento-2-clean-product-image-cache)
```

###  Alternatives

[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.2M1](/packages/fastly-magento2)[mage-os/module-automatic-translation

Automatic AI content translation for Mage-OS.

277.1k](/packages/mage-os-module-automatic-translation)[zepgram/module-rest

Technical module to industrialize API REST call with dependency injection pattern using Guzzle library

1326.2k](/packages/zepgram-module-rest)[graycore/magento2-graphql-introspection-cache

1015.2k](/packages/graycore-magento2-graphql-introspection-cache)[mage-os/mageos-common-async-events

Send REST requests to external endpoints asynchronously. This module implements the most common events like order creation and customer change.

147.7k2](/packages/mage-os-mageos-common-async-events)[mage-os/module-inventory-reservations-grid

Add a grid with the list of inventory reservations.

126.8k](/packages/mage-os-module-inventory-reservations-grid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
