Site logo

Archived topic

Choose different image size for GB image block

5 replies · Started by Anastasiya on December 15, 2022

Viewing posts 1–6 of 6

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.

Thanks David :-)

Greatly appreciate your help.

You're welcome

This archived topic is closed to new replies.