Download & Extend

Images are not deleted when imagecache_image_flush is called

Project:ImageCache
Version:4.7.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

The function imagecache_image_flush was not working for me:

<?php
function imagecache_image_flush($path) {
 
$presets = _imagecache_get_presets();
  foreach(
$presets as $presetid => $presetname) {
   
$path = file_directory_path() .'/imagecache/'. $presetname .'/'. $path;
   
file_delete($preset_image);
  }
}
?>

the file_delete variable is a typo. The correct function (that works for me) is:

<?php
function imagecache_image_flush($path) {
 
$presets = _imagecache_get_presets();
  foreach(
$presets as $presetid => $presetname) {
   
$path = file_directory_path() .'/imagecache/'. $presetname .'/'. $path;
   
file_delete($path);
  }
}
?>

Comments

#1

the bug is also in 4.7.x-1.x-dev

#2

Status:active» fixed

Thanks, this change must've been implemented in HEAD and 5 but not 4.7. I've corrected the function in the 4.7.x version.

#3

And...

If you have more than one preset my "fixed" function will not work (the $path variable keeps growing). Here is my fix to delete multiple presets:

<?php
function imagecache_image_flush($path) {
 
$presets = _imagecache_get_presets();
  foreach(
$presets as $presetid => $presetname) {
   
$delete = file_directory_path() .'/imagecache/'. $presetname .'/'. $path;
   
file_delete($delete);
  }
}
?>

#4

Thanks again. We used the exact same solution in 5 and HEAD (and now also 4.7).

<?php
function imagecache_image_flush($path) {
 
$presets = _imagecache_get_presets();
  foreach(
$presets as $presetid => $presetname) {
   
$ipath = file_directory_path() .'/imagecache/'. $presetname .'/'. $path;
   
file_delete($ipath);
  }
}
?>

#5

Status:fixed» closed (fixed)
nobody click here