0

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

enter image description here

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?

  • So you add an image size in the parent, but want to remove it in the child? How are you calling those functions? Is this on a hook? I strongly suspect the problem here is ordering, as well as not doing work on hooks. Am I right in thinking the code in your functions.php is just dumped in the root scope and not inside a function hooked to init or another action? – Tom J Nowell Jul 30 at 10:53
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 suitable srcset and sizes attributes 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.

| improve this answer | |
  • Oh this is great to know, thank you. Weird that they should leave them unlabelled like that. I'm just trying to streamline the space taken up by media in site installs. If I'm not calling images in Gutenberg blocks or in the classic WYSIWYG editor (just using ACF fields and calling the specific sizes i need in the templates directly) I don't need these even though they are there for a good reason, right? – mtm Jul 30 at 11:13
  • If you use wp_get_attachment_image() (which is the right approach whenever outputting <img> tags for attachments) then they'll be used to populate the srcset. – Jacob Peattie Jul 30 at 11:39
  • Yes yes I see – how clever. Very nice, thank you. – mtm Jul 30 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.