Snippet: Add/Remove Image Sizes
The following snippet example can be used to add new image size options and tabs to the Image Sizes panel. This can be useful if you are creating a 3rd party add-on for the theme. If you are creating a custom post types using our Post Types Unlimited plugin our plugin will automatically add image size options for post types (if enabled via the plugin settings) so you wouldn't need to use a snippet.
// Add & remove image sizes from the Image Sizes panel.
add_filter( 'wpex_image_sizes', function( $sizes ) {
// Remove "blog_post_full" image size.
unset( $sizes['blog_post_full'] );
// Add new image size "my_image_sizes".
$sizes['my_image_size'] = [
'label' => __( 'My Image Size', 'wpex' ),
'section' => 'other', // you could create your own tab instead - see below!
];
return $sizes;
}, 9999 );
// Add a new Tab to the Image Sizes panel.
add_filter( 'wpex_image_sizes_tabs', function( $tabs ) {
$tabs['my_custom_tab'] = esc_html__( 'My Custom Tab', 'total-child-theme' );
return 'tabs';
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
We recommend Code Snippets (100% Free) or WPCode (sponsored)