Home / Disable / Disable Auto-generated Image Sizes
Duplicate Snippet

Embed Snippet on Your Site

Disable Auto-generated Image Sizes

When we upload any media, WordPress automatically generates other extra sizes of it. It may eat up extra space on your server. Using this snippet, you can disable those extra images.

Code Preview
php
<?php
// Disable Auto Generated Images Sizes
add_action('intermediate_image_sizes_advanced', 'disable_image_sizes');
function disable_image_sizes($sizes) {
	
	//unset($sizes['thumbnail']);    
	//unset($sizes['medium']);      
	//unset($sizes['large']);        
	unset($sizes['medium_large']);
	unset($sizes['1536x1536']);    
	unset($sizes['2048x2048']);
	
	return $sizes;
	
}
add_action('init', 'disable_other_image_sizes');
function disable_other_image_sizes() {
	remove_image_size('post-thumbnail'); 
	remove_image_size('another-size');
}
add_filter('big_image_size_threshold', '__return_false');

Comments

Add a Comment