The effects of alcohol on
sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Is there a way to filter or seperate images uploaded by users within the WP media browser interface?
How-to and Troubleshooting
(@adamtheforumuser)
Estimable Member
Joined: 5 years ago
I've just realised on a site that is about to go live that the standard WP media browser for the site now also contains images uploaded by other users via the comments front-end.
I really need a way to filter the images from there. It would be useful to have access in this interface (although not vital). But it's really important that the users images can be hidden if desired so that I only see images uploaded by the content editors of this site that are connected to the posts/pages they author.
Is there an easy way to do this ?
(@asti)
Illustrious Member
Joined: 8 years ago
Hi AdamTheForumUser,
I'm really sorry, but there isn't an easy solution for this.
(@adamtheforumuser)
Joined: 5 years ago
Estimable Member
Posts: 84
May 22, 2021 11:04 am
@asti there's no plugin for example that you are aware of?
(@asti)
Joined: 8 years ago
Illustrious Member
Posts: 8195
May 23, 2021 11:07 am
I'm really sorry, but I'm not familiar with that kind of plugins.
(@adamtheforumuser)
Estimable Member
Joined: 5 years ago
I've come up with a solution that for our particular scenario is good enough, which I will share below in case useful for others.
Basically it alters the WP admin to only list images belonging to that particular author when using interfaces like the media library page. As this is pretty much a one person admin site it works although clearly it wouldn't be flexible enough for some others.
// hide users media upload (via wpdiscuz in the media library interface)
add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );
function wpb_show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if( $user_id ) {
$query['author'] = $user_id;
}
return $query;
}
I'm surprised there isn't some way to handle this at all in the plugin. You must have had others asking about this I assume ? Can I make it a wishlist request if you are keeping wishes from customers ?
(@asti)
Joined: 8 years ago
Illustrious Member
Posts: 8195
May 24, 2021 8:12 am
Thank you for sharing the code.
I'll ask the developers to take this into consideration. They'll add the code if it's possible.