You were headed in the right direction. There is another filter out there that handles intermediate_image_sizes_advanced
. You can add or remove custom sized thumbnails in there. Rather than NOT creating your landscape custom sizes on a Portrait upload, maybe try to only create the landscape custom sizes on a landscape upload.
add_filter( 'intermediate_image_sizes_advanced', function( $sizes, $metadata ) {
// Let's make sure we have the meta data we need before proceeding
if(!empty($metadata['width']) && !empty($metadata['height'])){
// Now let's make sure we have a Landscape being uploaded
if($metadata['width'] > $metadata['height']){
$sizes['home-slide-medium'] = array(
'width' => 1000,
'height' => 504,
'crop' => true
);
$sizes['home-slide-sm'] = array(
'width' => 500,
'height' => 252,
'crop' => tru
e);
$sizes['video-poster'] = array(
'width' => 780,
'height' => 512,
'crop' =>false
);
}
}
return $sizes;
}, 10, 2);
I tested it a few times on my end, but let me know whatcha think!!