Archived topic
New image sizes not shown in standard wp image block
10 replies · Started by nomadiceman on July 29, 2021
I've added the below new size:
add_action( 'init', function() {
add_image_size( 'new-featured-image', 800, 600, true ); // 800 width, 600 height, crop
} );
I can select these size in the customiser for the featured image, but it does not show in the standard Wordpress image block
The options showing in the Wordpress image block in a post is the stand small, medium, large
Any ideas how I can get the new size options in the image block?
* I have regenerated all sizes fyi
Hi there,
Can you try disabling ALL plugins and see if it appears? Some plugins (usually image optimization plugins) are known to mess with this. It's worth a try.
If it doesn't can you try temporarily changing to a default WordPress theme and check again?
Let us know.
Hi,
Ok so I've just disabled all plugins, the issue was still there
I then switched to Twenty Twenty One theme and that also didn't fix the problem
The new size is not showing in the standard Wordpress image block
Any ideas?
Hi there,
the Image size will only display the sizes available for the image you selected.
If you added the code after images were uploaded you will need to run the Regenerate Thumbnails plugin to create your new custom size.
You can quickly test this by uploading a new image, as WP will automatically create the sizes for new images.
If theres still an issue, then clear any plugin / browser caches
Hi guys,
I did the regenerate again to make sure.
I’ve got all plugins off. No caching. Twenty twenty theme
And still no image size option in standard image box
Im using wp 5.8
Any ideas? Driving me crazy 😜
I’m not a coder do I do struggle with it
I’ve seen this post and it seems I need to add extra code. Additional to the ones you suggest
https://wpmudev.com/blog/wordpress-image-sizes/
What do you think?
This part they say is needed for it to show in the image drop down
<?php
add_filter( 'image_size_names_choose','wpmudev_custom_image_sizes' );
function wpmudev_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
//Add your custom sizes here
'custom-image-square' => __( 'Square' ),
'blog-width' => __( 'Blog Content Full Width' ),
) );
}
What do you suggest?
Thanks again for you help 🙏
I would say go ahead and try the code and see if it works for you.
If not then you can mention this to WP's support team and see if they have a suggestion.
GP cannot control the standard image block from WP.
yeah ill give it a try
I was hoping this issue may have arisen before and been resolved already haha
Sounds good :)
Oh, I've figured it out.
I just added the part of the code from wpdev site that shows the options in the drop down.
and change the name of the images to what I use:
<?php
add_filter( 'image_size_names_choose','wpmudev_custom_image_sizes' );
function wpmudev_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
//Add your custom sizes here
'custom-image-square' => __( 'Square' ),
'blog-width' => __( 'Blog Content Full Width' ),
) );
}
now the sizes show in the gutenberg image block
:)
Thanks for sharing your solution!