The porosity of ordered mesoporous silica monoliths has been successfully used as nanoreactor for the elaboration of CoFe Prussian blue analogue nanoparticles. The nanocomposite exhibits a reversible photomagnetic effect different from that of typical powdered compounds due to particle size reduction.