In The Name of Allaah, The Most Merciful, The Bestower of Mercy
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 uncontrolled love of images; for when the heart is filled with Love of Allaah and a strong love for meeting Him [i.e. in the hereafter], the uncontrolled love for 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. [Soorah Yusuf: Ayah: 24]
This shows that sincerity to [Allaah] is a means to repelling [evil]. Therefore, repelling the original cause of something is repels the cause of that thing. And because of this, some of the Salaf said: ‘’Uncontrolled love is an agitation in empty hearts.” Meaning: [Hearts] emptied of other than what they crave for.
[Source: An excerpt from At-Tibbun Nabawiy’ by Imaam Ibnul Qayyim (rahimahullaah) with the footnotes and checking of Al-Allaamah Muhammad Haamid Al-Faqee (rahimahullaah) page180. Abridged and slightly paraphrased]