We present a Gupta–Bleuler quantization scheme for the electromagnetic field in time-dependent dielectric media. Starting from the Maxwell equations, a generalization of the Lorentz gauge condition adapted to time-varying dielectrics is derived. Using this gauge, a Gupta–Bleuler approach to quantize all polarizations of the radiation field and the corresponding constraint condition are introduced. In this case, the contributions of unphysical photons created from vacuum cannot be thoroughly eliminated, which further results in a surface charge density. Finally, a discussion of potential experimental tests is also made, which provides another possible way to detect the dynamical Casimir effect.