Home Forums Plugins WooCommerce Photo Reviews Media Library and Media Picker exclude review images

Media Library and Media Picker exclude review images

  • Author
    Posts
  • #46988

    jarfar
    Participant

    Hi, I’m looking for a way to exclude imported reviews photos from Media Library and Media Picker.

    For Media Picker, I tried filter below. This is called in Ajax way when Media Picker is opened. Even if it succeeds the Picker renders without any images.

      add_filter('wp_prepare_attachment_for_js', function($response, $attachment, $meta) {
        $reviews_upload_folder = get_option('_wcpr_nkt_setting');
    
        if ($reviews_upload_folder) {
          $user_reviews_upload_folder = $reviews_upload_folder['user_upload_folder'];
          $import_reviews_upload_folder = $reviews_upload_folder['import_upload_folder'];
          
          if (substr($meta['file'], 0, strlen($user_reviews_upload_folder)) === $user_reviews_upload_folder) {
            return;
          }
    
          if (substr($meta['file'], 0, strlen($import_reviews_upload_folder)) === $import_reviews_upload_folder) {
            return;
          }
        }
      
        return $response;
      }, 100, 3);

    Probably the best solution for Picker and Library, would be to use ajax_query_attachments_args filter which have parameters for WP_Query object as attribute. Can you please tell how to filter review images using ajax_query_attachments_args filter or another way to achieve it? Thanks

You must be logged in to see replies to this topic. Click here to login or register