How to get custom image sizes into media uploader dropdown?

I searched net to solve the problem with images size uploaded from media.
But not even one worked to me.
When I try to insert images from the media into post it does not show my custom image size 608 X 350 px

function setup_image_sizes() {
    if ( function_exists( 'add_image_size' ) ) {
        add_image_size( 'post-image', 608, 350, true );
    }

    function post_image_sizes($sizes){
        $custom_sizes = array(
            'post-image' => 'Post Image'
        );
        return array_merge( $sizes, $custom_sizes );
    }

    add_filter('image_size_names_choose', 'post_image_sizes');
}

add_action( 'after_setup_theme', 'setup_image_sizes' );

please advise me

Related posts

1 comment

  1. Try seperating it like this:

        function setup_image_sizes() {
            if ( function_exists( 'add_image_size' ) ) {
                add_image_size( 'post-image', 608, 350, true );
            }
        }
        add_action( 'after_setup_theme', 'setup_image_sizes' );
    
        function post_image_sizes($sizes){
            $custom_sizes = array(
                'post-image' => 'Post Image'
            );
            return array_merge( $sizes, $custom_sizes );
        }
        add_filter('image_size_names_choose', 'post_image_sizes');
    

    That way it is working in my setup.

    Additional Sources:
    custom image size with New Media Manager in wordpress 3.5
    http://ahjira.com/add-custom-image-sizes-to-media-library-size-selection-drop-down-list/

Comments are closed.