May one publicize their tzedakah contributions?
The Gemara interprets the pasuk (verse) “V’chesed leumim chatas” (the benevolence of the nations is sinful) to mean that the nations of the world do tzedakah solely l’hisyaher (out of haughtiness), in order to raise their status in the eyes of others. The same concept could apply to Yidden, lehavdil; if their intent when giving tzedakah is l’hisyaher, they are not doing a mitzvah, but an aveirah (sin).
Meforshim (commentators) question why it’s considered a sin. After all, we are encouraged to do mitzvos even shelo lishmah (with ulterior motives). Specifically regarding tzedakah, we are told that giving tzedakah is a mitzvah even if the motive is not altruistic. In fact, one who gives tzedakah so that his son may live is called a tzaddik (righteous).
Some explain that their sin is humiliating the poor man: by publicizing their gift they are using the poor man’s plight for their personal gain; but if done in a manner where the poor man won't be embarrassed or if the poor man isn’t humiliated by their actions, it’s not a problem.
Others are of opinion that giving tzedakah l’hisyaher is a problem in and of itself—even if the poor man is not embarrassed. They explain that l’hisyaher is baser than other ulterior motives. However, all agree that if one publicizes their charitable giving in order to serve as an example and inspiration to others, then it’s acceptable—and even praiseworthy—as long as no one’s feeling are hurt.