2

I'm using Media Entity Browser to let users add new or existing media files in a content type.

I have two groups. Business-A uploaded an image in a content. Business-A can re-use the image in writing other contents but Business-B should not be able to add it as an existing media for their own article.

I want that only a group can get access to its uploaded media. Because when I upload images using media browser, in default, all files get public accessed.

How can I restrict uploaded media files be added by other users.

1

Okey, it seems that view filter criteria is not the proper way to achieve this goal.

Contextual filter did the trick.

I added:

  1. Contextual filter of Media: Publisher ID
  2. Under WHEN THE FILTER VALUE IS NOT AVAILABLE: Provide default value
  3. Type: User ID from logged in user

Thanks to @mccrodp for helping out.

1

If you have Groups on your site with grouped access permissions, I would recommend using the Group module for less complex group permissions like this and OG for configuring more involved group permissions.

Using the Group module you will be able to section off the media and other content like this.

EDIT: I suggest you configure Group functionality / permissions directly on the File / media entity, rather than just the nodes they are added / used from. Failing that, I believe you will have to (clone and) override the view that the media entity browser uses and do some filtering based on group(s) of the media file author.

Then try using the user id of the author initially using static values to test your view. If the UI of the view does not provide what you are looking for, you might need to write your own Views Access Plugin. Here is one I wrote for Message Private module: InboxPermission.php. You could do similar.

  • Yes, I am actually using Group module on this. And I see no section of media on Group permissions. There is under /admin/people/permissions/ but don't have permission I wanted. All media uploaded by different users of different roles can still be accessed publicly. – John Rey Tanquinco Mar 3 '17 at 15:37
  • Have you configured Group functionality / permissions directly on the File / media entity though, rather than just the nodes they are added / used from? I believe you will have to (clone and) override the view that the media entity browser uses and do some filtering based on group(s) of the media file author. – mccrodp Mar 3 '17 at 15:58
  • I think the solution is on the filter criteria. I added filter as: Publisher ID of media. Operator: is equals to "value: with text box below", but what should be the value I put to be able to identify that it is filtered by the media file author? I tested with an author name, but the view is not showing any result. Also tried it in an actual implementation of adding media file. Thanks! – John Rey Tanquinco Mar 3 '17 at 16:58
  • Have you tried using the user id of the author? You might be doing so, but I suggest just using static values to test your view first. If the UI of the view does not provide what you are looking for, you might need to write your own Views Access Plugin. Here is one I wrote for Message Private module: InboxPermission.php. You could do similar. – mccrodp Mar 4 '17 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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