function image_style_flush

7.x image.module image_style_flush($style)

Flushes cached media for a style.

Parameters

$style: An image style array.

5 calls to image_style_flush()
image_default_style_revert in drupal-7.x/modules/image/image.module
Reverts the changes made by users to a default image style.
image_effect_delete in drupal-7.x/modules/image/image.module
Deletes an image effect.
image_effect_save in drupal-7.x/modules/image/image.module
Saves an image effect.
image_style_delete in drupal-7.x/modules/image/image.module
Deletes an image style.
image_style_save in drupal-7.x/modules/image/image.module
Saves an image style.

File

drupal-7.x/modules/image/image.module, line 971
Exposes global functionality for creating image styles.

Code

function image_style_flush($style) {
  // Delete the style directory in each registered wrapper.
  $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
  foreach ($wrappers as $wrapper => $wrapper_data) {
    if (file_exists($directory = $wrapper . '://styles/' . $style['name'])) {
      file_unmanaged_delete_recursive($directory);
    }
  }

  // Let other modules update as necessary on flush.
  module_invoke_all('image_style_flush', $style);

  // Clear image style and effect caches.
  cache_clear_all('image_styles', 'cache');
  cache_clear_all('image_effects:', 'cache', TRUE);
  drupal_static_reset('image_styles');
  drupal_static_reset('image_effects');

  // Clear field caches so that formatters may be added for this style.
  field_info_cache_clear();
  drupal_theme_rebuild();

  // Clear page caches when flushing.
  if (module_exists('block')) {
    cache_clear_all('*', 'cache_block', TRUE);
  }
  cache_clear_all('*', 'cache_page', TRUE);
}