function dynamic_banner_image_delete in Dynamic Banner 7
Same name and namespace in other branches
- 7.2 dynamic_banner.module \dynamic_banner_image_delete()
- 8.x dynamic_banner.module \dynamic_banner_image_delete()
This function will split the csv fid variable if it needs to be split And then delete those images from the file system and thier values in the db
1 call to dynamic_banner_image_delete()
- dynamic_banner_upload_image_validate in includes/
callbacks.inc - Validate/submit handler used for handling image uploads
File
- includes/
callbacks.inc, line 886 - Dynamic Banner Admin Pages and various other functions to make them work Most of the code in this file was derived from path module
Code
function dynamic_banner_image_delete($fid) {
if (strrpos($fid, ',')) {
// split the plain string into an array
$all_fids = explode(",", $imgfid);
// load all files at once
$all_files = file_load_multiple($all_fids);
foreach ($all_files as $file) {
if ($file) {
// When a module is managing a file, it must manage the usage count.
// Here we decrement the usage count with file_usage_delete().
file_usage_delete($file, 'dynamic_banner', 'banner', 1);
// The file_delete() function takes a file object and checks to see if
// the file is being used by any other modules. If it is the delete
// operation is cancelled, otherwise the file is deleted.
file_delete($file);
}
drupal_set_message(t('The image @image_name was removed.', array(
'@image_name' => $file->filename,
)));
}
}
else {
$file = $fid ? file_load($fid) : FALSE;
if ($file) {
// When a module is managing a file, it must manage the usage count.
// Here we decrement the usage count with file_usage_delete().
file_usage_delete($file, 'dynamic_banner', 'banner', 1);
// The file_delete() function takes a file object and checks to see if
// the file is being used by any other modules. If it is the delete
// operation is cancelled, otherwise the file is deleted.
file_delete($file);
}
drupal_set_message(t('The image @image_name was removed.', array(
'@image_name' => $file->filename,
)));
}
}