You are here

function _textimage_clear_cache_image in Textimage 7.2

Clear a cached image.

Parameters

mixed $preset: A preset name or ID.

string $file: Image file.

File

./textimage.admin.inc, line 690
Textimage admin page callback

Code

function _textimage_clear_cache_image($preset, $file) {
  if (is_numeric($preset)) {
    $pid = $preset;
  }
  else {
    $textimage_presets = textimage_get_presets();
    $pid = $textimage_presets[$preset]->pid;
  }
  $textimage_cache_dir = variable_get('file_default_scheme', 'public') . '://textimage/' . $pid;
  $uri = "{$textimage_cache_dir}/{$file}";

  // Clear textimage cache for this image.
  file_unmanaged_delete($uri);
  db_delete('textimage_image')
    ->condition('pid', $pid)
    ->condition('file', $uri)
    ->execute();
}