I have two image sizes and certainly until recently I used to be able to simply select these in the Image Settings > Image Size.
Now I only see the standard WordPress sizes (Thumbnail, Medium, Large) and Full Size.
I used to be able to select my Custom Sizes below?
add_image_size( 'blog', '800', '400', true );
add_image_size( 'portfolio', '570', '390', true );
See image (I used the Edit Custom Size to create the 'Resized to: 800 x 400 px option in the Image Size list)
Is this a change or a bug?
Right, the Custom Image Sizes added with add_image_size() are not used, you can, however, add custom sizes directly in the Inspector
I tested with older versions and this never seems to have been working properly
I've escalated the problem to the developers for a closer look
I'm sorry, it was my mistake.
Please let me show you how to add custom sizes so that they appear in both WordPress and Toolset (Blocks) Image size settings.
1. You should register the custom image sizes like so in the theme's functions.php:
add_image_size( 'first', '100', '120', true );
add_image_size( 'second', '300', '120', true );
//etc
2. Then, you should register the options to show in the GUIs, using your custom sizes:
add_filter( 'image_size_names_choose', 'the_custom_sizes_as_registered_by_you' );
function the_custom_sizes_as_registered_by_you( $sizes ) {
return array_merge( $sizes, array(
'first' => __( 'First' ),
'second' => __( 'Second' )
) );
}
3. Then, you need to upload an image that is bigger than your defined sizes
4. Now you will be able to insert such an image in a Toolset Image Field, and using the Dynamic Image Blocks Inspector Settings you can then select your custom sizes.
PS:
- If the image is smaller, or the sizes are not registered to hook "image_size_names_choose", it won't work. You can read more here about the WordPress hook image_size_names_choose: https://developer.wordpress.org/reference/hooks/image_size_names_choose/
- Make sure to load your in add_image_size() after_setup_theme hook: https://developer.wordpress.org/reference/hooks/after_setup_theme/
I will have a go at adding the filter in point 2.
The add_image_size was already in my child theme's functions.php and was previously all that was required to show up in the GUI. Only after very recent updates have they disappeared from the list. Elsewhere in the WordPress GUI I can see them listed, e.g. Genesis Featured Posts widget.
This is an old requirement in WordPress
As we tested it never was different, also in the WordPress media uploader. It's just new in the Blocks because the blocks are new and before we did not interact with the image_size_names_choose filter as there was no need for it (it was all shortcodes options).
In any case, it would be the expected form of implementation, because also the WP Media Uploader will require this, as the Second Tier also confirmed on the issue.
Please let me know if it works for you as well.
My issue is resolved now. Thank you!
Adding the code outlined in step 2 to my child theme's functions.php resolved the issue.