Closed (won't fix)
Project:
ImageCache Actions
Version:
7.x-1.x-dev
Component:
Custom Actions Module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Feb 2011 at 17:09 UTC
Updated:
1 Dec 2012 at 19:57 UTC
Comments
Comment #1
dman commentedThis is a known issue, with no tidy solution.
There currently is no per-image trigger, or no way to feed a refresh signal back up the pipeline to imagecache file storage, short of rebuilding all images all the time.
#642048: No, you can't pass 'arguments' to imagecache_actions. Here's why
Someone may eventually build a mechanism that does this, but it doesn't exist at the moment. Imagecache currently doesn't even provide a per-image rebuild, only a per-preset one.
#746982: Trigger a flush when imagefield's title is changed
#876674: Dynamic Watermark
My money is on a different system - still using imageapi as an engine, but a different pipeline - one without cache in the name - if you want generated images to respond to changes in data.
A new, different module that doesn't yet exist. - imageGen
Comment #2
bartmichael commentedI have solved this problem writing a custom module implementing hook_nodeapi
function MODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op =='update'){
if ($node contains CCK image field with Custom action){
imagecache_image_flush(PATH TO ORIGINAL IMAGE - for example $node->field_photo[0][filepath]);
}
}
}
This approach can be implemented in ImageCache Actions module, but generalization may be difficult:
the if() condition
and PATH TO ORIGINAL IMAGE
Thanks!
Comment #3
dman commentedimagecache_image_flush() ? that's new!
That is one part of the puzzle!
so, yes ... do-able. Good suggestion
Comment #4
fietserwinCan we flush 1 image or only the whole style directory? Or is this the requested functionality? I guess we can add that function if it is not there in core, we already augment core (image handling) with some features: module:// file wrapper, copy/import/export style. Leaving at postponed, as we first want to clean up the bug reports in the issue queue.
Comment #5
dman commentedNeed to see if there is an equivalent to imagecache_image_flush() in new D7 core.
I don't really think it's imagecache_actions job to go adding a nodeapi type hook just to capture this situation - but based on this use-case request, it's the only way.
Still, I guess hook_node_update is now a lot less overhead than hook_nodeapi, so it's the correct design for this...
Comment #6
fietserwinI think it is up to the image system to provide the API interface to such an action. I am not sure about the actual hook_node_update though, because this won't be needed in all situations, not even for each update, if e.g. it is about the title and the title has not changed. So that could mean deleting many images without the need for it. Anyway, we will see about that when we pick up this issue.
Comment #7
dman commentedYeah precisely.
I don't see the need for it in the majority of cases, but it's impractical to calculate which cases it *may* be needed for.
If implemented, it would need some highly sensitive switch - which I can't calibrate.
Or - just turn it on for global cases (hook_node_update) - by choice - and allow the admin to take the hit of regenerating when not strictly needed. If it can be per-node (which it will be) then it's not too painful.
No other optimal solution I can see.
Comment #8
fietserwinD7 image core module contains what is asked for:
When to call this function is so system dependent that we can't do that. So create your own hook to listen to the change that raises the need for flushing and call the above mentioned function.