Front propagation in one- and two-dimensional spatially modulated media is studied both experimentally and theoretically. The pinning-depinning phenomenon, long ago predicted by Pomeau [Physica D 23, 3 (1986)], is obtained and verified experimentally in a nematic liquid-crystal cell under various configurations of optical forcing. The front dynamics is characterized with respect to the different forcing parameters and the observations are compared with numerical simulations of a full model for the tilt angle of the liquid crystals under optical feedback. A spatially forced dissipative 4 model is derived near the points of nascent bistability. From this model we derive analytical results that account qualitatively for the observed front dynamics and pinning range. Localized structures of different sizes and shapes are found to exist inside the pinning range and experimentally proved to be stable states of the spatially forced system.