BuddyDev

Search

Organize user submitted images in the Media Library

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49705

    Hi there, when users are uploading images to their galleries, these are also appearing in the WP Media library.

    I don’t think it is very convenient that user submitted images are mixed with the rest of the image content of the site, like frontpage images, logos and backgrounds.

    Would it be possible to hide all user submitted images from MediaPress in the Media Library or to redirect them to a folder of its own in the library?

    Regards
    Carsten

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #49719

    Hello Carsten,

    Thank You for posting. You can use the following code to filter out MediaPress media from the Media library. Please give it a try.

    
    add_filter( 'ajax_query_attachments_args', function ( $query ) {
    	if ( is_admin() && is_user_logged_in() ) {
    		$query['meta_key']     = '_mpp_is_mpp_media';
    		$query['meta_compare'] = 'NOT EXISTS';
    	}
    
    	return $query;
    } );
    
    

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49720

    Hello Ravi, thanks for coming up with a solution to this issue, which I think would be of great help to all using BP.

    Unfortunately images uploaded with MediaPress still appear in the Media library.

    Regards
    Carsten

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #49737

    Hello Carsten,

    Thank you for the acknowledgement. Please try to debug by disabling all other plugins temporarily. Give it a try and let me know if the issue still persists or not.

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49739

    Hello Ravi, I moved the code snippet from bp-custom.php to functions.php, don’t know if that makes any difference.

    If your code works in your tests, I must have to debug on my site. It would be very helpfull to know if others have installed the code snippet on their site, to confirm that it is working on other sites.

    Regards
    Carsten

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49740

    By the way, does the code only apply to new uploads or does it apply on existing images in the library?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #49741

    Hello Carsten,

    Thank you for the acknowledgement. Yes, the code applies to both the existing and new media of MediaPress. Please try to debug it and let me know for any other assistance.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved