The following seems like an extremely basic algebraic topology question, but it's not something I ever learned, nor does it look familiar to the algebraic topologists I've asked.

Let $f:X\to Y$ be a map, inducing $f^*:H^*(Y)\to H^*(X)$. Hence the image $R$ of $f^*$ is a subring of $H^*(X)$. Is there a natural way to factor $f$ as $X \to Z \to Y$, such that $f^*$ factors as $H^*(Y) \twoheadrightarrow R \hookrightarrow H^*(X)?$

I have a particular $X,Y$ in mind (the inclusion of one compact complex manifold into another, each with even-degree cohomology) but I'm hoping phrases like "Postnikov tower", "cofibrant replacement", "mapping cone" will serve to give a general answer.