Praise be to Allah, the Lord of the Worlds; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
If it was confirmed that this Imam prostrated to that man as an act of glorification and worship of him, this is Kufr. It is not fit for such a person to be an Imam for the Muslims and the prayer behind him is not accepted because his prayer invalid.
The fact that he prostrated to other than Allah is an act of Kufr which renders all his actions void.
Allah Says (interpretation of meaning): {…"If you join others in worship with Allâh, (then) surely (all) your deeds will be in vain,….}[39:65].
Ibn Al Qayim said: ‘Deliberately prostrating to a Sheikh is one kind of Shirk (associating other partners to Allah). And it is considered an action of Shirk both for the person who prostrates (to the Sheikh) and an action of Shirk for the person to whom the prostration is made (the Sheikh in this case).
It is strange, however, for them to say that this is not a prostration but it is putting the head at the feet of the Sheikh as an act of respect and modesty.
The answer to these people is that whatever name they give it, the true meaning of prostration (Sujud) is to put the head down to the one who is prostrated to’.
Even if we presume that he made the Sajda as a greeting it is still forbidden to do so, but it is an action of a lesser degree than Shirk.
Ibn Taymiyah said: ‘There is no disagreement among the Imams (4 Imams) that it is forbidden to prostrate to great Sheikhs or others, or to kiss the ground before them or the like’. He also stated: ‘If someone does that as an act of worship or to get closer (to Allah), then this is considered to be the greatest sin. And whoever believes in this as an act of worship or to get closer to Allah, he is misguided and he is a slanderer.
He must be advised that this is not from our religion and it does not get him closer to Allah. If he insists, he should be called to repent, if he repents it is all right, otherwise he should be killed’. [End of quotation]
As regards prostrating to a grave, then this is a prostration for the purpose of worship and submission, and therefore it is Shirk.
The evidence about the above is the Hadith of Qays Bin Said that he told the Prophet (Sallallahu Alaihi wa Sallam): 'I came to Hiyra – and I found them prostrating to Maziyan (a brave knight) and you deserve more that we prostrate to you’. The Prophet (Sallallahu Alaihi wa Sallam) told him: “If you were to pass by my grave, would you prostrate to it?” The Prophet (Sallallahu Alaihi wa Sallam) carries on saying: “Do not do that, if I was to order someone to prostrate to somebody, I would order the women to prostrate to their husbands”. [Reported by Abu Dawud, and Al Hakim said that 'it is an authentic Hadith.' Al Dhahabi also stated a similar Hadith]
Sheikh al-Islam Ibn Taymiyah said: ‘The room of the Prophet Muhammad (Sallallahu Alaihi wa Sallam), the room of the Prophet Ibrahim (Alaihi Salaam) and the other burial places of Prophets and good people are not to be kissed or to be touched seeking blessing, according to the agreement of Muslim scholars. As for making Sujud (prostration) to such places it is Kufr’.
Therefore, you may find from the above details that what the Imam did is either Shirk or major sin. The person who commits an innovation that takes him out of Islam, such as prostrating to other than Allah, performing prayer behind such a person is not correct. Whoever performs prayer behind such a person has to repeat his prayer.
If this Bida’a (innovation) is not a Bida’a that makes a person Kafir, then it is not permissible to pray behind him unless there is nobody else to lead the prayer.
Ibn Taymiyah said: ‘If you can’t find other than him, like the Jumu’a (Friday) prayer which is held in one place only, or Eid prayers, or Hajj prayers behind the Imam of the season (of Hajj), then this prayer can be performed behind any good or debauched person, according to what is agreed on by Ahl al-Sunnah Wal Jama’a’.
As regards hanging pictures, if it is for other than living beings like the Kaaba, the Mosque, and the like, then there is no harm. But they should not be hanged in the Mosque as they distract the attention of the people who pray. However, if these pictures are pictures of living creatures, then it is a matter of difference of opinion. And if the purpose of the pictures is to glorify the person in the picture and cause an affection, then this is Haram.
With regard to your question about Abu Hanifa, you have to know that Sufism with today’s meaning did not appear until the end of the second century after Hijrah, and Abu Hanifa died well before that in the year 150 after Hijrah. So he was not even alive when this Sufism started.
Allah knows best.