Drupal is a registered trademark of Dries Buytaert
drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! linkit 7.0.14 Minor update available for module linkit (7.0.14). masquerade 8.x-2.2 Minor update available for module masquerade (8.x-2.2). video_embed_field 3.1.0 Minor update available for module video_embed_field (3.1.0). bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). editoria11y 3.0.0 Major update available for module editoria11y (3.0.0). trash 3.0.27 Minor update available for module trash (3.0.27). twig_tweak 4.0.0-alpha2 New alpha version released for module twig_tweak (4.0.0-alpha2). twig_tweak 4.0.0-alpha1 First alpha version released for module twig_tweak (4.0.0-alpha1). node_revision_delete 2.1.1 Minor update available for module node_revision_delete (2.1.1). commerce_paypal 2.1.2 Minor update available for module commerce_paypal (2.1.2).

flush_single_image

398 sites Security covered
View on drupal.org

Utility module to flush a single image from any image styles it may have generated for it.

This module provides a simple form to which you can provide a source image path (e.g. public://assets/foo/bar/image.jpg) and it will flush any styled image(s) that have been generated.

Background

This module was originally developed to solve an issue where daily imports from a closed third party system would replace image content on occasion but keep the filenames the same resulting in out of date images in the image style cache.

Service Class

See example below on how to use the service class included.

$path = 'public://assets/foo/bar/image.jpg';
$paths = \Drupal::service('flush_single_image')->flush($path);
foreach ($paths as $flushed_path) {
  \Drupal::messenger->addMessage(t('Flushed @path', ['@path' => $flushed_path]));
}

Drush Command

Image styles can also be flushed on a single image via Drush command. See code example below for usage.

drush flush_single_image public://assets/foo/bar/image.jpg --check-styles

Migrate Plugin

Migrate plugin included in module as well. See below for an example of how to use.

  process:
    path_to_file:
      -
        plugin: file_copy
        source:
          - /path/to/file.png
          - public://new/path/to/file.png
      -
       plugin: flush_single_image
       action: 'regenerate'

Activity

Total releases
1
First release
Mar 2026
Latest release
1 month ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
3.0.0 Stable Mar 11, 2026