The file_entity module has a hook_file_update which flushes the image style cache every time a file entity is saved.

This will some times be overkill, so it should be possible to disable this behaviour.

Files: 
CommentFileSizeAuthor
#8 1974630-file_entity-image_flush-7.patch1.65 KBhefox
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]
#6 1974630-file_entity-image_flush-6.patch1.65 KBhefox
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/file_entity/file_entity.file.inc.
[ View ]
#1 file_entity-allow_disabling_on_image_flush_on_update-1974630-1.patch436 bytesesbenvb
PASSED: [[SimpleTest]]: [MySQL] 821 pass(es).
[ View ]

Comments

StatusFileSize
new436 bytes
PASSED: [[SimpleTest]]: [MySQL] 821 pass(es).
[ View ]

This patch allows you to se a variable, file_entity_update_disable_flush, when set to 1 the image style cache will not be flushed.

Important: when porting the patch, remember to to the correct attribution according to http://drupal.org/user/989064

Status:Needs review» Postponed (maintainer needs more info)

image_path_flush() clears any cached versions of a specific file in all image styles. It doesn't flush cached media for an entire style like image_style_flush(), so it actually provides a sort of performance benefit (since you don't have to flush an entire style cache/the entire image cache to see any changes).

Disabling this would cause confusion to users if they used the "file replace" functionality to replace an existing image with a new image but the old image continued to be displayed throughout the website. A similar issue has already been brought up over browser caching of images #1701924: Add a cache-busting string to images.

Do you have a use case for disabling per-file image style cache flushing? :)

Status:Postponed (maintainer needs more info)» Needs review

The problem is that all styled images for a particular file ID are deleted EVERY TIME i just add a tag or change the description of the image file...

Since we use remote storage, the causes operations to be much slower than they should - and we use the manualcrop module for cropping the images, which will delete the styled images when a new crop is made, so we don't really need file_entity to clear it as well...

I know that a lot of users will benefit from the default behavior of file_entity and that's why I added an option to toggle it instead of removing it.

Status:Needs review» Needs work

Maybe we should more intelligently perform image_path_flush if $file->filesize != $file->original->filesize, which means the file *actually* changed.

Actually might be nice to have a utility function to use here:

file_entity_has_file_changed($file, $original) {
return $file->filesize != $original->filesize || $file->uri != $original->uri;
}

Issue summary:View changes
Status:Needs work» Needs review
StatusFileSize
new1.65 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/file_entity/file_entity.file.inc.
[ View ]

Status:Needs review» Needs work

The last submitted patch, 6: 1974630-file_entity-image_flush-6.patch, failed testing.

StatusFileSize
new1.65 KB
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]

syntax error, sigh

This saves 4 seconds on save with amazons3 module :)

Status:Needs work» Needs review