Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/media-fields/src/author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const authorField: Partial< Field< MediaItem > > = {
'user',
{
per_page: -1,
who: 'authors',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about this and that's why I hadn't included it in my main author field PR.

Can't a subscriber upload an attachment and be set as author of it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions!

For WordPress attachment post types, I'm pretty sure the author is the user who uploaded the file to the WordPress media library.

By default, no — subscribers cannot upload files in WordPress. The standard capability required to upload files is upload_files, which subscribers don't have.

Now, something that I didn't notice, but should have, is that contributors don't have upload_files caps by default either.

In fact, that makes me wonder if we should be rather be querying by roles cap instead for perfect accuracy, but I'm not sure that's possible.

{ who: 'authors' } is not perfectly aligned with upload_files, it's the closest we have and probably fits most cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we can query by caps. Said that, it seems there are more nuances in the query (at least for the pages one). Not sure if attachments are affected the same way.

_fields: 'id,name',
context: 'view',
}
) ) ?? [];
return authors.map( ( { id, name } ) => ( {
Expand Down
Loading