We show a technique that images the intensity distribution and local state of polarization of the optical field of high-quality factor optical modes confined in dielectric planar photonic crystal nanocavities. Based on energy-loss spectroscopy of swift electrons, the technique gives a spatial resolution improved by a factor of 30 compared to the optical diffraction limit. Moreover, because the energy loss is induced by coupling of the moving charges with the local density of states of the dielectric cavity, it is sensitive to the entire volume of the confined electric field, not just its evanescent contributions. This three-dimensional sensitivity paves the way for a highly resolved tomography of confined modes in dielectric photonic nanostructures.