In the case of a photon then planck's constant disappears?
No, because we are talking about massive particles, not massless particles. This is already established in getting to
where m is rest-mass, as I previously stated. If we're dealing with a massless particle, we don't have this relationship, as it is not possible to bring that particle to rest.
In your rearrangement with h on the lhs, you have to realise that as you vary m, you must also vary f.