Media Library is not loading on grid view in admin panel

Media Library is not loading on grid view and also featured image not select any image from post and page . The progress circle keeps spinning. Due to this issue, I am not able to add any image in the post as insert image option also opens in “grid view” by default.

The things I tried but not resolved my issue:

  1. Removed all plugins. Switch to twenty sixteen theme.
  2. Deleted whole wordpress installation. Installed fresh.
  3. Enabled script debug.Doesn’t show any error in console. Tried reloading the page too.

I am not able to do anything on my website for many days now, please help me.

Topic media-library uploads media images Wordpress

Category Web


Adding following code to functions.php file of theme folder worked for me.

add_action('admin_head', 'my_custom_style'); 
    
        function my_custom_style()
        {
            echo '<style>
        .media-frame.mode-grid .media-toolbar {
            
            height: 60px !important;
        }
      </style>';
        }

I ran into a similar issue with the same symptoms. What I determined was in my theme's function.php there was a DEBUG statement that output some html. While this was fine for browsing, when the POST request came into admin-ajax.php to refresh the thumbnails, it was causing the infinite spinning wheel and not showing images. I removed the output from functions.php and problem was resolved.

Not sure if this will work for you, but I found the issue by using the following command:

curl -X POST http://YOUR_DOMAIN_NAME_HERE/wp-admin/admin-ajax.php -d 'action=query-attachments&post_id=0&query[orderby]=date&query[order]=DESC&query[post_per_page]=40&query[paged]=1'

I know this thread is old, but I just solved this and maybe my solution can help others. I also was not able to create any posts. My site had the list view working, but not the grid view, and every upload actually did go through although the upload feature would display the typical (media upload failed) error. I was able to view all of my photo uploads in /wp-content/uploads even after the library error.

I am new to PHP, and learning how to write my own scripts. I wrote a script to hide menu items/notices on the admin pages for my client, and I used:

add_action('admin_init' , 'makeDashboardPretty');

to hook into the admin pages to do this. This would run my script before anything on the admin page would load. One of the items I hid was my theme's menu item, which apparently needs to load in order to get the media library/posting working. I think the echo ''; ?> css in my script would prevent my theme from enabling the media library/posting features.

I changed my admin hook to:

add_action('wp_after_admin_bar_render' , 'makeDashboardPretty');

which allowed my script to initialize after my theme's menu item did. This enabled me to hide the item and still get the theme working.


I had same problem before few days. I tried to use the function ob_start();

on top in function.php file of active theme. And Media Library loaded well.


I faced same issue on my wordpress site. After the lot of debugging i fixed my problem step by step.

  1. First add given below code your db-config.php
define('SCRIPT_DEBUG', TRUE);
define('WP_DEBUG', TRUE);
define( 'WP_DEBUG_LOG', true );
  1. Then goto /wp-includes/js/wp-util.js files and find the code $.ajax( options ) on line number 100(depand your wordpress version) insert given below code into your file
deferred.jqXHR = $.ajax( options ).done( function( response ) {
  try {
      response = JSON.parse(response);
  } catch (Exception) {
      response = response;
  }

Please check your may be resolved.

  1. if you Removed constant from db-config.php
define('SCRIPT_DEBUG', TRUE);
define('WP_DEBUG', TRUE);
define( 'WP_DEBUG_LOG', true );   
  1. Then compress your /wp-includes/js/wp-util.js file code and put your compressed code into /wp-includes/js/wp-util.min.js

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.