2

My apologies If I am not clear, but I will try my best to explain my problem.

After upgrading wordpress to 4.7.3. I am facing a super slow wordpress media library load(i.e. wp-admin/upload.php). It takes like 5 minutes to load the images first glance of image and another similar time to search the desired Image. This May be because the site has huge amount of images(in 10's of thousands) and categories.But The slowness is beyond tolerance level.

I found that once the user start typing to search for image on every key press It is sending ajax request to search image. (May be a room for optimization).

So to make the search so that it fires ajax only after 3rd character. I was not able to stop wp fire ajax on client side so I tried to stop as soon as ajax is received in server site using following code in function.php

function acf_media_fix(){ 
 if(is_user_logged_in() && strpos($_SERVER['HTTP_REFERER'],"wp-admin/upload.php")!== false){
  $query = $_POST['query']['s']; 
  $query_length = strlen($query);
  if($query_length>0 && $query_length<3){wp_die();}    
  return;
 }    
}

add_action( 'wp_ajax_query-attachments','acf_media_fix',-2);

It worked, but any suggestion on how to do same on js part.

Is there some way to save the mysql query of this whole operation into some text file.

Thank you

SD433
  • 143
  • 11

0 Answers0