I'm no expert, but here what I have experienced with sideways pics.
I'm not sure about a Mac, but I first had this rotating photo issue after some updates on Windows. When I would turn the camera to portrait to take a picture, then view on a computer, the program would sense it was sideways and automatically turn it upright for viewing. But then on uploading it to my school website, it would be sideways. Best as I can figure is the in the background techie language stuff said, "I'm still sideways". The way I got around it... 1. Don't turn the camera. 2. If a photo was taken with a turned camera, open the photo, edit by cropping a smidge or adjusting, then save as another name. Then when I would upload, the orientation would be correct . At least that worked for me.
Just one thought, not a sure solution.