Apologies if has been covered somewhere already, although I did try to search for likely terms
I think I know what's going on with FT randomly rotating photos -- the EXIF data stored in a photo can specify metadata, including the orientation of the camera when the photo was taken. I have pix taken with my phone held vertically (portrait mode) which are nevertheless reported as 4160x2340 by the "identify" utility in the ImageMagick package. They display correctly oriented on my phone laptop because they know how to interpret the EXIF data.
When you upload a photo to FT, it appears to do some processing on the image (including enforcing max height/width) before storing the image, and I bet whatever software they are using to do this processing, does not know about this EXIF attribute.
Thus in order to upload a photo to FT and preserve the correct orientation, it needs to have this EXIF attribute deleted (and the image rotated locally before it is uploaded, if necessary). ImageMagick's "convert" utility has a "-auto-orient" flag which will do this. Most photo editing software probably lets you edit the EXIF data also?
For further reading:
jpeg exif orientation
jpeg delete exif orientation
ImageMagick docs for convert -auto-orient
Here are 3 different versions of the same source image. On my laptop all three appear correctly oriented.
This is an upload of the original raw image; FT incorrectly displays it in landscape mode:
For this upload I resized the image ("convert -resize 25%") but did not change any of its other attributes; FT also shows this in landscape:
Then I ran "convert -resize 25% -auto-orient" and now the uploaded version displays correctly: