How to get WordPress to resize images for srcset?

srcset is populated with all sizes of the image that are the same aspect ratio as the original image.

The reason smaller images are added to srcset if you upload the exact size is because that means that the default resized versions like medium and large will have the same aspect ratio. However, when using a custom cropped image size those smaller sizes will be created with the same aspect ratio as the original image, not the cropped custom size.

The solution to this is to register additional custom sizes with add_image_size() that are smaller than the custom size but have the same aspect ratio. WordPress will then be able to use these to populate srcset when didplaying your custom size.