You are here

function media_acquiadam_flush_image_styles in Media: Acquia DAM 7

Clear the cached external images of assets.

This does not clear thumbnails for assets that are unused in the system.

This helper function is in place so we can limit our flushing to just asset images instead of everything the imagecache external might be used for.

Parameters

array|int $assetIds: A asset ID or IDs to limit the flushing to.

1 call to media_acquiadam_flush_image_styles()
media_acquiadam_flush_cache in includes/media_acquiadam.cache.inc
Clears given asset IDs from the local cache.

File

includes/media_acquiadam.cache.inc, line 138
Cache helpers and associated logic.

Code

function media_acquiadam_flush_image_styles($assetIds = []) {
  if (!is_array($assetIds)) {
    $assetIds = [
      $assetIds,
    ];
  }
  module_load_include('inc', 'media_acquiadam', 'includes/media_acquiadam.image');

  // Go through each image style and clear out the cached asset folder for it.
  $styles = image_styles();
  foreach ($styles as $style) {
    foreach ($assetIds as $asset_id) {
      $uri = media_acquiadam_image_style_path($asset_id, $style, 'acquiadam', '');
      file_unmanaged_delete_recursive($uri);
    }
  }
}