In The Name of Allaah, The Most Merciful, The Bestower of Mercy.
Shaikhul Islaam Ibn Taymiyyah [rahimahullaah] said:
Those people whose hearts are infatuated with images are to receive the greatest punishment and the smallest reward, because if the heart of the one who is infatuated with images continues to be attached and is enslaved by it, then various types of evils, loss and corruption will be gathered for him, which none can enumerate except Allaah. And even if he is safe from committing a major lewd act, the continuous attachment of the heart to the image without committing a lewd act is a greater than the harm that afflicts a person who commits a sin and then repents and thus the effect of that sin ceases to exist in his heart.
The greatest aspect of this calamity is when the heart turns away from Allaah, because indeed when the heart tastes the worship of Allaah and sincerity to Him, there will never be anything more sweet than that- neither more tasty and enjoyable nor better. A person does not abandon something beloved to him except due to another beloved thing which is more beloved to him or due to fearing harm. The heart is turned away from a corrupt love by an upright love or due to fearing harm. Allaah [The Exalted] said about Yusuf [alayhis salaam]:
[ڪَذَٲلِكَ لِنَصۡرِفَ عَنۡهُ ٱلسُّوٓءَ وَٱلۡفَحۡشَآءَۚ إِنَّهُ ۥ مِنۡ عِبَادِنَا ٱلۡمُخۡلَصِينَ – Thus it was, that We might turn away from him evil and illegal sexual intercourse. Surely, he was one of Our chosen, guided slaves. [Surah Yusuf. Aayah 24] So, Allaah turned His servant away from that which would plunge one into evil due to inclining towards an image and being attached to it, and turns him away from lewd conduct due to his sincerity to Allaah. This is why this can occur before a person tastes the sweetness of servitude to Allaah and sincerity to Him – when one is overcome by his soul through following its (evil) desires; however when one tastes the sweetness of sincerity to Allaah and his heart becomes strong, it subdues its desires without the great remedy (needed for) rectification. [Ref 1]
Imaam Ibnul Qayyim [rahimahullaah] said:
Hearts that are emptied of Love for Allaah -hearts that are turned away from Him and seeking remedy from others besides Him- are afflicted with an infatuation with images; for when the heart is filled with Love of Allaah and a strong love for meeting Him [i.e. in the hereafter], this infatuation with images is repelled from it. And for this reason, Allaah [The Most High] stated about Yusuf [alayhis-salaam]: [كَذَٰلِكَ لِنَصْرِفَ عَنْهُ السُّوءَ وَالْفَحْشَاءَ ۚ إِنَّهُ مِنْ عِبَادِنَا الْمُخْلَصِينَ -Thus it was, that We might turn away from him evil and illegal sexual intercourse. Surely, he was one of Our chosen, guided slaves]. This shows that sincerity to [Allaah] is a means to repelling [evil]. And because of this, some of the Salaf said: ‘’Infatuation is an agitation in empty hearts.” Meaning: [Hearts] emptied of other than what they crave for. [Ref 2]
[Ref 1: Al-Uboodiyyah 114-115. slightly paraphrased]
[Ref 2: An excerpt from At-Tibbun Nabawiy. page180. slightly paraphrased]