Skip to content

Snippet: Add/Remove Image Sizes

// 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'] = array(
        'label'     => __( 'My Image Size', 'wpex' ), // Label
        'width'     => 'my_image_size_width', // id for theme_mod width
        'height'    => 'my_image_size_height', // id for theme_mod height
        'crop'      => 'my_image_size_crop', // id for theme_mod crop
    );

    // Return sizes
    return $sizes;

}, 9999 );
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)
Back To Top