How to Bulk Delete Unattached Images from WordPress Site

delete unattached images wordpress

If you see the following error while deleting images in bulk in WordPress :
"Error 503 Service Unavailable

Service Unavailable

Guru Meditation:

XID: 000000000

Varnish cache server"

Step 1. First step would be to Increase the Nginx Buffers :
Open the nginx.conf file

 vi /etc/nginx/nginx.conf 


 vi /usr/local/nginx/conf/nginx.conf

and update(or add if not present already) to http or server or location context :

 set client body size to 2M 
client_max_body_size 2M; 


 set client body buffer size to 512K
client_body_buffer_size  512K;

Step 2. Now open the nginx master file :

 vi /etc/nginx/sites-available/master


 vi /usr/local/nginx/sites-available/master

Add these lines just after the server block :

client_header_buffer_size 32k;
large_client_header_buffers 16 512k;

Step 3. Apart from these settings, there has also been a known issue with the PHP Security Plugin. This plugins limits the maximum length allowed for a URL.
This affects bulk deleting as WordPress sends a URL with GET request with the ids of all the media to be deleted, so if someone is deleting more than 100 images at one time, the URL passed would be a very large one.

Now restart Nginx and test

 service nginx restart
© 2024 WPOven Inc. All rights reserved. WPOven® and WordPress® are registered trademarks.
WPOven is the best Managed WordPress hosting for agencies and businesses that want to succeed. With Unlimited sites hosting option, its easy to use and manage, so you can focus on growing your business. 
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram