Al-Ḥāfiẓ Ibn Rajab said in his Fath al-Bārī:
“This ḥadīth points to the prohibition of building mosques over the graves of the righteous and of depicting their images inside them, as the Christians do. Each of those two practices is unquestionably forbidden in its own right: making images of human beings is unlawful, and erecting mosques upon graves is likewise unlawful, as other texts—which will be cited later—make clear.
“The pictures that Umm Ḥabībah and Umm Salamah mentioned finding in that church were painted on its walls and similar surfaces; they were flat images that cast no shadow. Producing representations in the likeness of the prophets and the pious in order to seek blessing from them or to use them as intercessors is forbidden in Islam; it is a form of idol-worship, and concerning such people the Prophet (peace and blessings be upon him) said they will be the worst of Allah’s creation on the Day of Resurrection. Likewise, making images merely so that people may look at them and emulate them, or simply for ornamentation and amusement, is forbidden; it is counted among the major sins, and whoever does so is among the most