Unset image sizes before images are uploaded

You get $sizes as array, where size name is a value, not a key Try this //remove sizes with init hook and remove_image_size add_action(‘init’, function ($sizes) { remove_image_size(‘2048×2048’); remove_image_size(‘1536×1536’); return $sizes; }); // or just return sizes you need add_filter(‘intermediate_image_sizes’, function ($sizes) { return [‘thumbnail’,’medium’,’large’]; });

How to use default image as featured image by implement some code in function.php

To make your existing code work you’ll also need to override has_post_thumbnail: add_filter( ‘has_post_thumbnail’, ‘__return_true’ ); since your theme is probably guarding get_the_post_thumbnail() with has_post_thumbnail(), so that now needs to return true in the default case. However there’s still a chance that this won’t work, if the theme you’re using goes directly to get_post_thumbnail_id(). To … Read more