Crystal engineering based on defect passivation with metal ions doped into halide perovskites is of considerable interest for tailoring the photoelectric properties of perovskites. Herein, a simple and robust approach for doping metal ions into a thin all‐inorganic CsPbBr3 perovskite film by employing metal–organic framework nanoparticles is presented. Zeolitic imidazolate framework‐8 nanoparticles, which can adsorb water, are dispersed and embedded in a thin perovskite film. The particles self‐decompose at a certain humidity, releasing Zn2+ ions into nearby perovskite crystals. The Zn2+ ions efficiently passivate the undercoordinated defect sites of the defective perovskite crystals, resulting in environmentally stable and enhanced photoluminescence of the perovskite with a quantum yield of ≈14%, more than 24 times greater than that without nanoparticles. Further, a thin Zn‐doped CsPbBr3 film is employed to fabricate arrays of ultraviolet photodetectors, and ≈90% of the initial photocurrent is maintained over 15 d in RH 60%, facilitating the development of a dual‐mode image sensor using which programmed images are visualized based on both photocurrent and photoluminescence.