For a real analytic periodic function $\phi:\mathbb{R}\to\mathbb{R}^d$, an integer $b \ge 2$ and $\lambda\in(1/b,1)$, we prove that the box dimension and the Hausdorff dimension of the graph of the Weierstrass function $W(x)=\sum_{n=0}^{\infty}{{\lambda}^n\phi(b^nx)}$ are both equal to $$\min\left\{\log_{\lambda^{-1}}b,\,1+\left(\,d-q\,\right)\left(1+\log_b\lambda\right)\right\},$$ where $q = q(\phi, b, \lambda)$ denotes the maximum dimension of all linear spaces $V < \mathbb{R}^d$ such that the projection $\pi_V W$ is Lipschitz.