How to accept images at multiple sizes and aspect ratios and display as standardized image size / ratio?

You are right when you predict you will be at the mercy of the uploaders, and they can be very inventive when it comes to sizing and aspect ratio!

My approach is to be very verbose in the front-end UI as to what images are acceptable – “Please upload standard ratio images for example 1200×900, or 800×600. Please note your images will be cropped to this ratio so failure to….” (etc)

If they ignore that, then their images still hit my functions file where I unset the standard WP image sizes, and set my own. A lot of them HARD crop, so it’s uploader beware I’m afraid (I left a couple of bonus functions at the end here too):

//Remove all the defaults

function remove_default_image_sizes( $sizes ) {

 //Default WordPress
 unset( $sizes[ 'thumbnail' ] );
 unset( $sizes[ 'medium' ] );
 unset( $sizes[ 'medium_large' ] );
 unset( $sizes[ 'large' ] );

 //With WooCommerce you can remove these too
 //unset( $sizes[ 'shop_thumbnail' ]); // Shop thumbnail (180 x 180 hard cropped)
 //unset( $sizes[ 'shop_catalog' ]); // Shop catalog (300 x 300 hard cropped) 
 //unset( $sizes[ 'shop_single' ]); // Shop single (600 x 600 hard cropped)

 return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced','remove_default_image_sizes' );

//Add our new sizes, xome hard cropped...

add_image_size( 'custom-large', 1200, 900, false);
add_image_size( 'custom-medium', 800, 600, false);
add_image_size( 'custom-thumb', 260, 195, false);
add_image_size( 'custom-blog-cropped', 1200, 500, true );
add_image_size( 'custom-avatar-cropped', 110, 110, true );

//Bonus functions

// Disable WordPress responsive srcset images
add_filter( 'max_srcset_image_width', create_function( '', 'return 1;' ) );

//Remove the hardcoded width and height WP loves setting
function remove_img_attr( $html ) {
 return preg_replace( '/(width|height)="\d+"\s/', "", $html );
}
add_filter( 'post_thumbnail_html', 'remove_img_attr' );