Archived topic
Choose different image size for GB image block
5 replies · Started by Anastasiya on December 15, 2022
Hi,
I wanted to see if there is a way to display all available registered image sizes in GB image block. I have a custom image size registered in the theme but the GB image block shows only standard Wp image sizes. Is there a way to change that?
Hi there,
you have to tell WP to include the your image sizes in the editor using the image_size_names_choose filter.
Heres an example PHP Snippet that does that:
add_filter( 'image_size_names_choose', function() {
return [
'thumbnail' => __( 'Thumbnail', 'textdomain' ),
'medium' => __( 'Medium', 'textdomain' ),
'medium_large' => __( 'Medium Large', 'textdomain' ),
'large' => __( 'Large', 'textdomain' ),
'full' => __( 'Full Size', 'textdomain' ),
'your_custom_size' => __( 'Your Custom Size label', 'textdomain' ),
];
} );
You can adjust the last option: 'your_custom_size' => __( 'Your Custom Size label', 'textdomain' ), to match your size.
Thank you David!
It worked like a charm!
Is there a library of all filters and possible applications that I can browse to find the solutions? There is so much that can be done with GeneratePress and I would love to learn more complex integrations or ways to use the theme and blocks plugin.
That filter is a core WordPress filter, of which there are probably 100s :)
See here:
https://codex.wordpress.org/Plugin_API/Filter_Reference
For GeneratePress here are a few of them:
https://docs.generatepress.com/collection/filters/
For GenerateBlocks there are very few, as we try to use the core filters in our blocks.
If theres something specific you need just ask and we can try and point you in the right direction.
Thanks David :-)
Greatly appreciate your help.
You're welcome