Took me longer than anticipated because I went the wrong way trying to solve this. Left it on the backburner for a few days before going back to it with another approach
There’s now a new site setting: crop_tall_images
which is enabled by default and will generate a crop of tall images instead of generating a thin thumbnail.
https://github.com/discourse/discourse/commit/667dd54a23b705d4286ac0b2a8d398c13675963b