2026年11月12日

2026年11月12日

WordPress Media Library Not Opening? How to Fix It

This article is a localized edition of the Japanese original. Read the Japanese original

Introduction

You try to set a featured image on a post and the Media Library goes blank. You open the library and not a single image appears. You try to upload a file and get an "HTTP error". Media Library problems often come from several causes at once.

Symptoms and Causes

Main reasons the Media Library won't open:

  • JavaScript errors: JS from a plugin or theme prevents the media modal from initializing
  • Permalink settings problems: Ajax requests are not routed correctly
  • Not enough PHP memory: The memory limit is hit while the image list is generated
  • File upload limits: upload_max_filesize or post_max_size is too small
  • Directory permissions: There is no write permission on wp-content/uploads/

How to Fix It

Step 1: Check the browser console and network

1. Press F12 → Console and look for JS errors

2. In the Network tab, open the Media Library and check the request to /wp-admin/admin-ajax.php

3. If the response is -1 or empty, it is a nonce or permission problem

Step 2: Resave the permalinks

wp rewrite flush --hard

You can do the same in the admin screen under Settings → Permalinks → "Save Changes".

Step 3: Deactivate plugins to check

# Deactivate all plugins
wp plugin deactivate --all

# If the Media Library opens, reactivate plugins one by one to find the cause
wp plugin activate akismet
wp plugin activate woocommerce

Step 4: Raise the file upload limits

// wp-config.php
define('WP_MEMORY_LIMIT', '256M');
; php.ini or .htaccess (set with php_value)
upload_max_filesize = 64M
post_max_size = 128M
max_execution_time = 300
memory_limit = 256M
# .htaccess
php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value memory_limit 256M

Step 5: Check the upload directory permissions

# Check the permissions of wp-content/uploads/
ls -la wp-content/

# Set to 755 (directories)
chmod 755 wp-content/uploads/
chmod -R 755 wp-content/uploads/

# Change the owner to the web server user (Apache/Nginx)
chown -R www-data:www-data wp-content/uploads/

Step 6: When uploads fail with an HTTP error

// functions.php — lower JPEG quality to reduce memory use for large images
add_filter('jpeg_quality', function() { return 82; });

// Set automatic resizing of large images
add_filter('big_image_size_threshold', function($threshold) {
    return 2560;  // images 2560px and larger are scaled down automatically
});
// wp-config.php — use the GD library for image processing (when it is more memory-efficient than Imagick)
define('WP_IMAGE_EDITOR_ENGINE', 'WP_Image_Editor_GD');

Step 7: Repair the Media Library data

# Regenerate image thumbnails
wp media regenerate --yes

# Update attachment metadata
wp eval '
$attachments = get_posts(["post_type" => "attachment", "numberposts" => -1]);
foreach ($attachments as $attachment) {
    wp_update_attachment_metadata(
        $attachment->ID,
        wp_generate_attachment_metadata($attachment->ID, get_attached_file($attachment->ID))
    );
}
echo "Done.\n";
'

Caveats

  • Setting the upload directory permissions to 777 is a security risk. Use 755 or 775.
  • If you use Imagick for image resizing, errors are more likely on servers with little memory. Consider switching to the GD library.

Summary

If the Media Library won't open, check the console for JS errors, resave the permalinks, then isolate plugins, in that order. Upload errors are often solved by raising upload_max_filesize and memory_limit and checking the permissions of wp-content/uploads/. Related articles: How to increase the PHP memory limit, Correct file permission settings

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲