The same question in other words:

How a file can inherit edit permission from node permission which is attached to?

Hi all,

I have 2 node types: articles and cars.

A file entity field is attached to both so users, through media module, can attach images to articles and cars.

Now I want a moderator role that can edit files attached to cars ONLY.

How to accomplish this?

Granting "Edit any files" to Moderator allow him to edit every files, articles attached files also, but I don't want this.

Thank you for any help

1 Answer 1


Maybe I've found a workaround.

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


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(&$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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.