I'm the author of the fast gallery project. I've noticed that a lot of users are having problems setting up imagecache namespaces properly. Is there a way to do programatically? If so, how? Is there an API for this?
I'm the author of the fast gallery project. I've noticed that a lot of users are having problems setting up imagecache namespaces properly. Is there a way to do programatically? If so, how? Is there an API for this?
Comments
Comment #1
drewish commentedit's not documented but imagecache_action_save() and imagecache_preset_save() should do what you want. it'd be really helpful as you puzzle your way through them document those functions and contribute a patch back.
Comment #2
drewish commentedComment #3
drewish commentedalso see #283875: Unable to create actions
Comment #4
rapsli commentedThanks. This did the job, but there seems to be some really weird problem. Here is my preset and the actions:
They are properly being imported, but when I use them, the crop action is not being applied, only the scale action. When I go into the imagecache ui and just save the preset again it works just fine.
Don't really know where the problem lies.
Comment #5
dopry commentedno clue... how about sprinkling some drupal_set_message around to figure out what is going on or... I can't troubleshoot this for you... you're gonna have to do some of that yourself.
Comment #6
roblinton commentedHi,
Chances are you've solved this already, but just in case...
When the actions are saved with imagecache_action_save() the cached version of the presets is cleared with imagecache_presets() - which is passed true to force a reload from the db. But the actions for each preset are accessed via imagecache_preset_actions() which further stores its return value in a static var. Consequently the actions aren't refreshed after the first one is stored in a static return var in imagecache_preset_actions(), even though they're stored in the db.
It works through the form because imagecache_ui_preset_load() clears the caches and forces a reload before anything is stored the static var in imagecache_preset_actions().
imagecache_preset_save() returns the preset with the presetid set in the array so you can do away with your db_last_insert_id stuff. Then you can fix the caching by calling:
After all your updates are made. That's imagecache_preset_actions() for each preset you set dynamically, and imagecache_presets(true) once after everything's in the db.
Cheers.
Comment #7
dopry commentedalso the ID should be automatically added to the $preset array, you don't need to db_last_insert_id() IIRC.