When you take a photo, straight lines remain straight. Sun rays are straight, so they remain straight. Since all sun rays have their origin at the sun, they must be pointing away from the sun radially. Both in 3D and in the image you take.
Now, take your image, and extend the visible sun rays back towards their origin. You will notice that those extensions converge exactly where the sun happens to be in the image (if it's within the image).
The illusion stems from two origins:
The sun is within or near to the visible image frame, but not visible itself because it is hidden by the clouds.
Your eyes correctly locate the 2D position of the sun within the image, but attribute a too small z-coordinate to it (distance from the observer). This z-coordinate cannot be determined from a single 2D image, and is thus just a guess by your visual cortex.
This guess assumes that the directions of the sun rays have no strong z-coordinate, but in reality, they are almost z-coordinate only.