But if you're fighting for a good cause, don't worry much about it. Because reputation is merely what others think of you. Character, on the other hand, is what you truly are.
Worry more about what Allah has to say about you. Because that's what matters most.
Try very hard to gain His love. Love those on earth, and those in heaven will love you. [Hadis qudsi]. And when Allah loves you, He will throw affections into people's heart towards you.
But if you want to make people like you at the expense of your obedience to Allah, think again.
Because whoever seeks the pleasure of Allah at the risk of displeasing the people, Allah will take care of him and protect him from them. But whoever seeks the pleasure of the people at the risk of displeasing Allah, He will abandon him to the care of the people. [Hadis narrated by Aishah r.a]