The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Is there a way to f...
 
Share:
Notifications
Clear all

Is there a way to filter or seperate images uploaded by users within the WP media browser interface?

6 Posts
2 Users
1 Reactions
1,248 Views
AdamTheForumUser
Posts: 69
Topic starter
(@adamtheforumuser)
Estimable Member
Joined: 4 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 ?

5 Replies
Asti
Posts: 7645
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi AdamTheForumUser,

I'm really sorry, but there isn't an easy solution for this. 

Reply
2 Replies
AdamTheForumUser
(@adamtheforumuser)
Joined: 4 years ago

Estimable Member
Posts: 69

@asti there's no plugin for example that you are aware of?

Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7645

I'm really sorry, but I'm not familiar with that kind of plugins.

Reply
AdamTheForumUser
Posts: 69
Topic starter
(@adamtheforumuser)
Estimable Member
Joined: 4 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 ?

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7645

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. 

Reply
Share: