1

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

1 Answer 1

3

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.