Self-consistent field model for electrostatic correlations and inhomogeneous dielectric media