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);
    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)),
    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

#1 media_gallery-remove-message-1781260-1.patch702 bytesSyg


Syg’s picture

patch changing remove confirm message.

Moloc’s picture

Status: Active » Needs review
Issue tags: +Beta9-blocker

Tagging. Issue for Media 2.x

tobiasb’s picture

Version: 7.x-1.0-beta8 » 7.x-2.x-dev
Status: Needs review » Reviewed & tested by the community

In 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.

pmackay’s picture

What is remaining to be done to close this to achieve Beta9 release?

pmackay’s picture

Issue summary: View changes

Add Media version

brantwynn’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

IMO, 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)


Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.