• I wanted custom image sizes for blog posts and I have used the following code to add custom image sizes to my WordPress theme. But it doesn’t work correctly.

    Problem

    It shows different image sizes than the ones I have put. I don’t code and have no idea how to do this right.

    Screenshot – https://puu.sh/m8VPx/6d05327b58.png

    Code used

    // Make sure featured images are enabled
    add_theme_support( 'post-thumbnails' );
    
    // Add other useful image sizes for use through Add Media modal
    add_image_size( 'features-small', 225, 100 );
    add_image_size( 'features-medium2', 450, 200 );
    add_image_size( 'features-blog', 900, 400 );
    add_image_size( 'features-big', 1800, 800 );
    add_image_size( 'features-uploaded', 2700, 1200 );
    
    // Register the three useful image sizes for use in Add Media modal
    add_filter( 'image_size_names_choose', 'mystile_custom_sizes' );
    function mystile_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'features-small' => __( 'Custom Small' ),
            'features-medium2' => __( 'Custom Medium2' ),
    	'features-blog' => __( 'Custom Blog' ),
            'features-big' => __( 'Custom Big' ),
            'features-uploaded' => __( 'Custom Uploaded' ),
        ) );
    }

    Thanks for any help.

Viewing 1 replies (of 1 total)
  • Anonymous User 14733231

    (@anonymized-14733231)

    Just Add bellow snippet and try

    if ( function_exists( ‘add_image_size’ ) ) {
    add_image_size( ‘new-size’, 350, 250, true ); //(cropped)
    }
    add_filter(‘image_size_names_choose’, ‘my_image_sizes’);
    function my_image_sizes($sizes) {
    $asize= array
    (
    “new-size” => __( “New Size”)
    );
    $newsizes = array_merge($sizes, $asize);
    return $newsizes;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Add Custom Image Sizes to Backend’ is closed to new replies.