When you use the contextual link to remove the file from the gallery, the file is deleted (if it's not used elsewhere) by the file core module.
The file module compares the field value with the original one and delete it.
// Compare the original field values with the ones that are being saved.
$original_fids = array();
if (!empty($original->{$field['field_name']}[$langcode])) {
foreach ($original->{$field['field_name']}[$langcode] as $original_item) {
$original_fids[] = $original_item['fid'];
if (isset($original_item['fid']) && !in_array($original_item['fid'], $current_fids)) {
// Decrement the file usage count by 1 and delete the file if possible.
file_field_delete_file($original_item, $field, $entity_type, $id);
}
}
}
We may change the confirm message that explains this file will be available to specify it won't if it's not used elsewhere in the website or people won't understand.
Example :
function media_gallery_remove_item_form($form, &$form_state, $node, $file) {
// Set the breadcrumb.
$node_url_arguments = entity_uri('node', $node);
drupal_set_breadcrumb(array(
l(t('Home'), NULL),
l($node->title, $node_url_arguments['path'], $node_url_arguments['options']),
));
$form['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
$form['fid'] = array(
'#type' => 'value',
'#value' => $file->fid,
);
return confirm_form($form,
t('Are you sure you want to remove %file from the gallery %gallery?', array('%file' => $file->filename, '%gallery' => $node->title)),
"media-gallery/detail/{$node->nid}/{$file->fid}",
t('The file will still be available in the media library to use elsewhere on this site. Note: File no longer in use will be deleted.'),
t('Remove file')
);
}
Note: i'm using Media 2.x
Comments
Comment #1
Syg commentedpatch changing remove confirm message.
Comment #2
moloc commentedTagging. Issue for Media 2.x
Comment #3
tobiasbIn my use-case, it will be better that the file leaves in a "default" files pool. But for this generic way, I believe its ok.
EDIT: This could be a solution http://drupal.org/project/file_lock for my use case.
Comment #4
pmackay commentedWhat is remaining to be done to close this to achieve Beta9 release?
Comment #4.0
pmackay commentedAdd Media version
Comment #5
saltednutIMO, the English used in #1 is a bit confusing.
Changed to "The file will still be available in the media library if used elsewhere on this site. Note: Unused files will be deleted" and committed. (I still gave you credit, @Syg)
http://drupalcode.org/project/media_gallery.git/commit/31298f5