When there are multiple styles, can not be removed:

function image_path_flush($path) {
  $styles = image_styles();
  foreach ($styles as $style) {
    $path = image_style_path($style['name'], $path); // $path variable is covered
    if (file_exists($path)) {
      file_unmanaged_delete($path);
    }
  }
}
if($file = file_load($fid)){
  image_file_delete($file);
  // $file->uri: public://photos/Tulips.jpg
}
/*
$path completely changed:

public://styles/thumbnail/photos/Tulips.jpg
public://styles/medium/styles/thumbnail/photos/Tulips.jpg
public://styles/large/styles/medium/styles/thumbnail/photos/Tulips.jpg
public://styles/photos_large/styles/large/styles/medium/styles/thumbnail/photos/Tulips.jpg
public://styles/photos_medium/styles/photos_large/styles/large/styles/medium/styles/thumbnail/photos/Tulips.jpg
public://styles/photos_thumbnail/styles/photos_medium/styles/photos_large/styles/large/styles/medium/styles/thumbnail/photos/Tulips.jpg
*/

/*
The correct style of caching in:
public://styles/thumbnail/photos/Tulips.jpg
public://styles/medium/photos/Tulips.jpg
public://styles/large/photos/Tulips.jpg
public://styles/photos_large/photos/Tulips.jpg
public://styles/photos_medium/photos/Tulips.jpg
public://styles/photos_thumbnail/photos/Tulips.jpg
*/

Comments

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure what the problem is with the documentation that you are trying to report -- could you please provide more details of what is wrong with the documentation?

Here's a link to the doc page...
http://api.drupal.org/api/function/image_path_flush/7

eastcn’s picture

Component: documentation » image system

Sorry, I have been lazy, I clicked on that link.

In fact, image_path_flush () can not remove all the style of the image. $path variable in the loop is covered.

I think it is this a bug. in the image module.

jhodgdon’s picture

Title: Documentation problem with image_path_flush » image_path_flush cannot remove the style of the image
Status: Postponed (maintainer needs more info) » Active

OK, changing issue title and status as well so the image folks might take a look at it.

jg314’s picture

Have there been any updates on this? I can't seem to figure out how to remove the styles from a particular image.

Thanks.

bryancasler’s picture

seanr’s picture

Issue summary: View changes

I seem to have encountered this myself with Image Javascript Crop. Create a style with the standard core crop. Add content with an image using that style and save. Then add the javascript crop action to the style, above the default crop. Edit the node. I can successfully save crop settings, but the actual image is never updated. Go back and edit the core crop action and save (without changing anything). Now all images get rebuilt and the one with the custom crop is finally correct.

Very annoying, to say the least. ;-)

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.