I’m developing a child theme (mms-child) based on a simple parent (mms – also my dev). I am quite used to the usual way of defining custom image sizes within functions.php as follows:
add_theme_support( 'post-thumbnails' ); add_image_size( 'Size name', 2000, 9999 );
I have removed all instances of this in the child theme’s functions file, and checked to make sure there is nothing like this in the parent theme either. So – I am expecting nothing in my list of thumbnail sizes other than the standard WordPress defualts.
But the media area of the WordPress settings tells me this:
The sizes listed below are the crop and resize formats defined by
mms-child
I have been though all files in both themes and can find nothing that would define these image sizes. I don’t need them. How can I locate this instruction and remove it?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
These images sizes are defined by WordPress, and were added in WordPress 5.3. The comments in the source code describe them like this:
These sizes are meant to enhance the way WordPress displays images on
the front-end on larger, high-density devices. They make it possible
to generate more suitablesrcsetandsizesattributes when the
users upload large images.The sizes can be changed or removed by themes and plugins but that is
not recommended. The size “names” reflect the image dimensions, so
changing the sizes would be quite misleading.
The “Image sizes are defined by the current theme” screen from your screenshot is not part of WordPress. It must be from a plugin that you’re using that is not aware of these new sizes and is incorrectly attributing them to your theme. You would need to ask its developer why.
You can stop them being generated by adding this line to a Must Use plugin:
remove_action( 'plugins_loaded', '_wp_add_additional_image_sizes', 0 );
But you really shouldn’t, as they were added for a good reason.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
