Firstly, big thank you for the work with this module. It rocks. :) So far I've been using the HEAD version, 31 May, while writing up a custom module. As to date I've found no bugs.
This issue is more about the integration with third party modules that use the imagecache, CCK, etc.
Is it possible to define a lock on the preset to prevent it's deletion while other modules are still using it.
My first thoughts were for a lock similar to that of the module defined content types, but that would require significant coding just for a minor issue, as well as changes to the db,etc.
A nice simple solution would be to define a hook_imagecache_delete_preset that would allow modules to check their own data to suggest that the preset is being used.
eg: something like this.
<?php
// imagecache.module
function imagecache_ui_preset_delete_form($form_state, $preset = array()) {
if (empty($preset)) {
drupal_set_message(t('The specified preset was not found'), 'error');
drupal_goto('admin/build/imagecache');
}
$in_use = module_invoke_all('imagecache_delete_preset', $preset);
if (!empty($in_use)) {
$error_list = theme('item_list', $in_use);
drupal_set_message(t('The specified preset can not be deleted due to the following reasons;') . $error_list, 'error');
drupal_goto('admin/build/imagecache');
}
$form = array();
$form['presetid'] = array('#type' => 'value', '#value' => $preset['presetid']);
return confirm_form(
$form,
t('Are you sure you want to delete the preset %preset?',
array('%preset' => $preset['presetname'])
),
'admin/build/imagecache',
t('This action cannot be undone.'),
t('Delete'), t('Cancel')
);
}
// photo.module
/**
* Implementation of hook_imagecache_delete_preset().
*/
function photo_imagecache_delete_preset($preset) {
if (_photo_present_in_use($preset)) {
return t('Photo module is using this preset.');
}
}
function _photo_present_in_use() {
// for testing
return true;
}
?>
Cheers
Comments
Comment #1
drewish commentedI'd like to see this as well. I want to have the image module use imagecache as a backend for doing the derivatives but need to ensure that a couple of sizes are always available.
Comment #2
dopry commentedanyone wanna write alock patch?
Comment #3
alan d. commentedThe function hook_imagecache_default_presets() does this job nicely.
@Thanks yhahn