function designkit_upload_delete in DesignKit 6
Same name and namespace in other branches
- 7 designkit.admin.inc \designkit_upload_delete()
Element validator for image delete. Handles file delete and value setting tasks all at once.
1 string reference to 'designkit_upload_delete'
- _designkit_form_alter in ./
designkit.admin.inc - Implementation of hook_form_alter() for spaces_features_form, system_theme_settings.
File
- ./
designkit.admin.inc, line 125
Code
function designkit_upload_delete($element, &$form_state) {
$name = end($element['#parents']);
if (isset($form_state['values']['designkit_image'][$name][$name])) {
// Delete the old image.
if (!empty($form_state['values']['designkit_image'][$name]['delete'])) {
$old_file = $form_state['values']['designkit_image'][$name][$name];
if (file_exists($old_file->filepath)) {
file_delete($old_file->filepath);
imagecache_image_flush($old_file->filepath);
}
if ($old_file->fid) {
db_query('DELETE FROM {files} WHERE fid = %d', $old_file->fid);
}
unset($form_state['values']['designkit_image'][$name]);
}
else {
$form_state['values']['designkit_image'][$name] = $form_state['values']['designkit_image'][$name][$name]->fid;
}
}
}