Cropping thumbnails to specific dimensions on front end post

media_handle_sideload handles the uploads in the same way the normal upload does. That means, when you upload a remote image (YouTube thumbnails in your case) it will automatically create the thumbnails of sizes registered using add_image_size.

So, what you need to do is create a thumbnail of desired size and call it in your loop.

function my_setup() {
    //Support Thumbnails
    add_theme_support( 'post-thumbnails' );

    //Add Thumbnail Sizes
    add_image_size( 'youtube', 224, 120, true );
}
add_action( 'after_setup_theme', 'my_setup' );

And then in your loop;

if ( '' != get_the_post_thumbnail() ) {
    the_post_thumbnail( 'youtube' );
}

error code: 523