We propose using the optomechanical interaction to create artificial magnetic fields for photons on a lattice. The ingredients required are an optomechanical crystal, i.e. a piece of dielectric with the right pattern of holes, and two laser beams with the right pattern of phases. One of the two proposed schemes is based on optomechanical modulation of the links between optical modes, while the other is an lattice extension of optomechanical wavelength-conversion setups. We illustrate the resulting optical spectrum, photon transport in the presence of an artificial Lorentz force, edge states, and the photonic Aharonov-Bohm effect. Moreover, wWe also briefly describe the gauge fields acting on the synthetic dimension related to the phonon/photon degree of freedom. These can be generated using a single laser beam impinging on an optomechanical array.