Show Custom Image Sizes in the Editor Size Menu
Adds every image size registered by your theme and plugins to the size dropdown in the editor and media modal, instead of only Thumbnail, Medium, Large and Full.
Opens WPIDE on
Code
add_filter( 'image_size_names_choose', function ( $sizes ) {
foreach ( wp_get_registered_image_subsizes() as $name => $data ) {
if ( isset( $sizes[ $name ] ) || in_array( $name, array( 'medium_large', '1536x1536', '2048x2048' ), true ) ) {
continue;
}
$sizes[ $name ] = sprintf( '%s (%d x %d)', ucwords( str_replace( array( '-', '_' ), ' ', $name ) ), $data['width'], $data['height'] );
}
return $sizes;
} );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.