I have seen the proof of the reverse here, but I cannot quite prove it the other way around.
I was thinking about using the fact that, for every $x \in X$, there is a ball $B_x$ where $f(B_x)=c\in \mathbb{R}^n$, and then I could argue that $X=\cup B_x$. Since every $B_x$ is connected and has more than one point from $X$, I would conclude that $X$ is the reunion of connected subsets, each one with at least one point in common with another one.
Is that approach correct? I feel like I have missed something around.