In this work we consider an extended electromagnetic theory in which the scalar state which is usually eliminated by means of the Lorenz condition is allowed to propagate. This state has been shown to generate a small cosmological constant in the context of standard inflationary cosmology. Here we show that the usual Lorenz gauge-breaking term now plays the role of an effective electromagnetic current. Such a current is generated during inflation from quantum fluctuations and gives rise to a stochastic effective charge density distribution. Because of the high electric conductivity of the cosmic plasma after inflation, the electric charge density generates currents which give rise to both vorticity and magnetic fields on sub-Hubble scales. Present upper limits on vorticity coming from temperature anisotropies of the CMB are translated into lower limits on the present value of cosmic magnetic fields. We find that, for a nearly scale invariant vorticity spectrum, magnetic fields Bλ>10-12 G are typically generated with coherence lengths ranging from subgalactic scales up to the present Hubble radius. Those fields could act as seeds for a galactic dynamo or even account for observations just by collapse and differential rotation of the protogalactic cloud.