Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:74:5

And uncleanliness avoid  

and shun ˹all˺ defilement, ˹this rijz˺ was explained by the Prophet (s) to be the graven images; in other words, persist in shunning them.
القرآن:٧٤:٥

وَالرُّجْزَ فَاهْجُرْ  

{والرُّجز} فسره النبي ﷺ بالأوثان {فاهجر} أي دم على هجره.

See similar narrations below:

Collected by Bukhārī

Cover me! Story of the second encounter with Jibrīl in his full form

bukhari:4Ibn Shihāb > Abū Salamah b. ʿAbd al-Raḥman > Jābir b. ʿAbdullāh al-Anṣārī

as he was narrating about the period of Wahī (Revelation): "While I was walking, ˹suddenly˺ I heard a voice from the sky. I looked up and saw the same Angel who had visited me at the cave of Ḥirāʾ sitting on a chair between the sky and the earth. I got afraid of him, came back ˹home˺ and said, 'Cover me!' Then Allah ﷻ revealed: 'O you who covers himself [with a garment]' Arise and warn.' until His statement 'And idolatory, avoid.' (Muddaththir 74:1-5) After this the revelation started coming strongly, frequently and regularly."  

It was corroborated by ʿAbdullāh b. Yūsuf and Abū Ṣāliḥ, and was corroborated by Hilāl b. Raddād from Zuhrī and Yūnus and Maʿmar said portions of it.
البخاري:٤قَالَ ابْنُ شِهَابٍ وَأَخْبَرَنِي أَبُو سَلَمَةَ بْنُ عَبْدِ الرَّحْمَنِ أَنَّ جَابِرَ بْنَ عَبْدِ اللَّهِ الأَنْصَارِيَّ قَالَ

وَهُوَ يُحَدِّثُ عَنْ فَتْرَةِ الْوَحْىِ فَقَالَ فِي حَدِيثِهِ: «بَيْنَا أَنَا أَمْشِي، إِذْ سَمِعْتُ صَوْتًا مِنَ السَّمَاءِ، فَرَفَعْتُ بَصَرِي، فَإِذَا الْمَلَكُ الَّذِي جَاءَنِي بِحِرَاءٍ جَالِسٌ عَلَى كُرْسِيٍّ بَيْنَ السَّمَاءِ وَالأَرْضِ۔ فَرُعِبْتُ مِنْهُ فَرَجَعْتُ فَقُلْتُ زَمِّلُونِي! فَأَنْزَلَ اللَّهُ تَعَالَى {يَا أَيُّهَا الْمُدَّثِّرُ * قُمْ فَأَنْذِرْ}» إِلَى قَوْلِهِ «{وَالرُّجْزَ فَاهْجُرْ} فَحَمِيَ الْوَحْىُ وَتَتَابَعَ۔»  

تَابَعَهُ عَبْدُ اللَّهِ بْنُ يُوسُفَ وَأَبُو صَالِحٍ وَتَابَعَهُ هِلاَلُ بْنُ رَدَّادٍ عَنِ الزُّهْرِيِّ وَقَالَ يُونُسُ وَمَعْمَرٌ بَوَادِرُهُ