boonebgorges / buddypress-docs

GNU General Public License v3.0
107 stars 44 forks source link

Docs cannot be selected from the media library #753

Open edwindekuiper opened 1 month ago

edwindekuiper commented 1 month ago

Documents that are uploaded cannot be selected from the media library. This allows the same documents to be uploaded each time. Is there an option to use the media library, instead of uploading duplicate files?

there are no files visible in the mediatab?

cheers, Edwin

Schermafbeelding 2024-06-05 174249

boonebgorges commented 3 weeks ago

Hello, and thanks for the ticket.

The current behavior is intentional. The Media Library in the WP Dashboard shows you pretty much everything that's been uploaded to the site. This is OK for a blog, since it's likely to have a small number of authors. But on a BuddyPress installation, nearly any member can upload an attachment to a document. So the plugin prevents unauthorized access to attachments by limiting the Media Library view to only those items that are attached to the current Doc. Here's the relevant filter: https://github.com/boonebgorges/buddypress-docs/blob/259edd8937cc3f045177b983697ddc560a173538/includes/attachments.php#L440

On your installation, you could disable this behavior by commenting out this line: https://github.com/boonebgorges/buddypress-docs/blob/259edd8937cc3f045177b983697ddc560a173538/includes/attachments.php#L36 (or by removing the callback using remove_filter())

In the future, it would be nice to use a more fine-grained approach to Media privacy. Instead of showing only those attachments associated with the current Doc, we should show only those attachments that are "available to" the current user. At a minimum, this could be "items I've uploaded". But it could also include "items uploaded to Docs attached to groups of which I am an admin". It gets complicated fast :-D

Another consideration: If the same uploaded file can be attached to more than one Doc, then modifying or deleting the attachment while looking at one Doc could have unintended consequences elsewhere.

I'll consider improvements on this in the future.