Create imagecache preset programmatically in D6
Last modified: August 25, 2009 - 06:16
If you need to create your own imagecache presets from code have a look at following example:
// Preset
$imagecachepreset = imagecache_preset_save(array('presetname' => 'MYPRESETNAME'));
// Action
$imagecacheaction = new stdClass ();
$imagecacheaction->presetid = $imagecachepreset['presetid'];
$imagecacheaction->module = 'imagecache';
$imagecacheaction->action = 'imagecache_scale_and_crop';
$imagecacheaction->data = array('width' => '200', 'height' => '200' );
drupal_write_record('imagecache_action', $imagecacheaction);Thanks to Eikaa & mavimo for this
If you call this in your _install hook the preset gets installed when your module is enabled.
Now for uninstalling this imagecache preset in this case you can do the following:
imagecache_preset_delete(imagecache_preset_by_name('MYPRESETNAME'));Thanks to tylerwaits for this
