Opened 3 years ago

Last modified 2 years ago

#13235 new enhancement

Simplify and add filtering to call to display author for media

Reported by: sbressler Owned by:
Priority: normal Milestone: Future Release
Component: Media Version: 3.0
Severity: normal Keywords: has-patch commit 3.2-early
Cc:

Description

The author displayed on the media page (upload.php) is not filterable in any way currently. This patch adds a filter for the author ('media_author'). Perhaps more filters should be added for other fields, but at the least I would like to add this filter.

Attachments (6)

13235.diff (1.1 KB) - added by sbressler 3 years ago.
13235.2.diff (594 bytes) - added by sbressler 3 years ago.
Call the_author for unattached media just like attached media
13235.3.diff (1.0 KB) - added by sbressler 3 years ago.
13235.4.diff (763 bytes) - added by sbressler 3 years ago.
Refresh for WordPress 3.1 with list-table-media.
13235.5.diff (872 bytes) - added by sbressler 3 years ago.
Use WP functions to generate URL (per Nacin's request)
13235.6.diff (618 bytes) - added by sbressler 3 years ago.
Again, a refreshed patch for the changes to trunk.

Download all attachments as: .zip

Change History (19)

It looks like there are already filters that can be leveraged for this.

Perhaps I'm missing something, but which? The only other one I see in upload.php or edit-attachment-rows.php is 'media_row_actions', but that's specifically for the actions available to something in the media library I think.

the_author and get_the_author have filters.

Doesn't look like the direct setup_userdata call can be changed easily. That said, if you want to filter the entire column, why not remove the column and add your own?

Leaving in 3.1 for sure as that's the earliest we're going to touch media/upload. When we do, we're likely going to break a lot, and we don't want more filters in place we need to at least consider back compat for.

Well, one could filter 'the_author' and/or 'get_the_author_display_name', which actually does seem like a better idea than adding this filter. However, then the code in upload.php should probably be changed to use the_author or run through the filter instead of echoing $author->display_name. Thoughts?

  • Summary changed from Add filter for author on media page to Simplify call to display author for unattached media

Thanks for the feedback, nacin. I was making this much harder than I realized. Now I would just propose simplifying the way the author is called for unattached media.

Call the_author for unattached media just like attached media

  • Summary changed from Simplify call to display author for unattached media to Simplify and add filtering to call to display author for media
  • Keywords has-patch added
  • Keywords needs-refresh added; has-patch removed
  • Milestone changed from Awaiting Triage to Future Release

Future release for now, as these need refresh against trunk due to the list tables.

Refresh for WordPress 3.1 with list-table-media.

  • Keywords has-patch added; needs-refresh removed

Added a refreshed patch. Should be good to go for 3.1.

  • Keywords commit added
  • Milestone changed from Future Release to 3.1

Use WP functions to generate URL (per Nacin's request)

Again, a refreshed patch for the changes to trunk.

I hope that the above patch can be committed soon so I can stop refreshing it :)

  • Keywords 3.2-early added
  • Milestone changed from 3.1 to Future Release

Just tested this on tip of trunk and the latest patch (13235.6.diff) still works great. However, I realized that it no longer achieves the purpose I was hoping. While the author text displayed can be filtered using the standard 'the_author' filter, the href added cannot be filtered as desired. Any ideas for how this could be achieved properly? Would adding a separate filter like originally proposed (first patch uploaded) be that bad an idea?

Would like to get this in before 3.2 freeze so I can stop thinking about this year-old ticket.

Note: See TracTickets for help on using tickets.