How to grant "edit any file" permission only to files attached to a certain node type?
Maybe I've found a workaround.

Files editing is accessible in a general direct way (bypassing their nodes) by the following url:

www.mysite.com/file/[fid]/edit


So only through this link a Moderator can have access and edit ANY file (please tell me if this is correct).

So, doing:

/**
 * Implementation of hook_menu_alter()
 */
function helper_menu_alter(&amp;$items) {
  // Provide custom access callback for direct files edit url
  $items['file/%file/edit']['access callback'] = 'helper_direct_file_edit_url_access_callback';
}

/**
 * Custom access callback
 */
function helper_direct_file_edit_url_access_callback() {
  // Disallow direct files edit url to everyone but superadmin
  if (!_helper_is_user_superadmin()) {
    return FALSE;
  }
  return TRUE;
}


Moderators with "Edit any file" permission (and everyone in anycase) cannot directly access to edit files, but they can edit files with media module through nodes they have edit access to (e.g. cars)

Do you think guys this could be a good workaround?

There is a better way to accomplish this?

Thank you very much