add_action( 'after_setup_theme', 'remove_plugin_image_sizes', 999 ); function remove_plugin_image_sizes(){ remove_image_size('medium_large'); remove_image_size('large'); remove_image_size('1536x1536'); remove_image_size('2048x2048'); }
This code removes four image sizes that were added by a WordPress plugin or theme.
Steps:
1. The function ‘remove_plugin_image_sizes‘ is called after installing the theme (‘after_setup_theme’) with priority 999.
2. The function removes four image sizes: ‘medium_large‘, ‘large‘, ‘1536×1536‘, ‘2048×2048‘.
3. This allows you to optimize page loading and reduce the size of stored images in WordPress.