The thing is lots of people try to justify their own self-centered actions with "Everybody does selfish things" or even "every action is ultimately selfish". So in this case the argument would be "You're just doing it for the positive PR".
Now giving to charity without any positive side effect for you personally, meaning a net negative side effect for you as you have less than before, would often serve as a counter example of selfishness called "altruism", as it is purely for the benefit of the other person. Now of course a particularly rigorous observer might raise questions like "But doesn't it just give you this warm feeling of having done the right thing? And isn't it ultimately about giving yourself that feeling rather than for the sake of itself or the other person?". But a) that's almost impossible to prove or disprove and b) that would kinda warp the definition of selfishness, because it's somewhat different in both motivation and effect from the negatively connotated destructive short-sighted self-centration that regards other either with antagonism or apathy.
And if you follow a consequentialist perspective you might even argue that telling other people about it is good, precisely because it introduces more motives to do something and if selfishness breeds virtuous acts than even selfishness could be seen as a virtue.
The problem is that what you set as your goal determines your path or rather "judges the effectiveness of your path". So if the goal is to create good publicity you might find "more effective" means to boost your public standing than solving societal problems; in fact grand gestures and oversized symbolism might perform even better than actually doing something, because the end goal is not to solve a problem but to get people to talk about how you are great for tackling a problem. So in the worst case it might even be counterproductive to actually solve the problem. Like a doctor who instead of treating a disease keeps you in a cycle of pain and relief. They'd certainly improve your quality of life through the relief, but not sustainable, not for your sake but for theirs.
The problem is, again, what is in your head when doing something is in your head. Like people can speculate that if you're not talking about it that you're doing it for the sake of it, while if you're talking or even boasting about it you're doing it for the sake of something else, but in the end you could just be more subtle about the boasting, like you don't have to talk about it when others already do. Like "XYZ gave me that house and he's so humble to instruct me not mention that to anybody" might end up being more effective word-of-mouth propaganda than if he had bought nationwide television coverage about it. While actually doing it for the sake of it and being brought into a position where you're forced to disclose something like that against your will might look more damaging.
So that's not technically about morality but about perception.
On top of that you have questions about the morality of charity to begin with.
Because its effects both financially and morally don't scale with money. Like life is a money drain and the cost of staying alive is often something of a fixture. Now for poor people the ratio of (necessary cost of living)/(income or wealth) is rather high in the worst case even bigger than 1, so if they give x% of their income that might already cut into the segment that was dedicated for necessary expenses and thus marks a real sacrifice, while if you are rich that ratio becomes much smaller and so the impact of a donation is much smaller. So individually the donation of a poor person has more moral weight than that of a rich person. Financially it's the opposite.
However beyond the pure financial aspect, the higher you go, the more you enter a new aspect and that is power and agency.
Like when you're donating millions you reach the level where it's debatable whether that was "your" money to begin with. Because you likely only are able to reap that amount of money by being the figurehead of an enterprise where you take the credit for the work of thousands or more people. So to an extent you're not speaking with your voice but with theirs. And your charity is at least partially also theirs, but you're the one taking the credit.
Even worse when "your charity" is directed towards your employees. Because in that case you're essentially taking their money than giving it back, and while financially that's without consequence, doesn't matter how the money moves what matters is where it ends up, but socially that's a transaction and the implication of that might be overlooked but they are HUGE.
Like many cultures have a morality of "giving is better than taking" and "being grateful if something is given to you." and that makes a lot of sense if you have a mutual society of equals that has a share and barter economy. It becomes a lot more sinister if you have a price based transactional economy.
Because what that essentially says as a consequence is that "being poor is being immoral". Like if a rich person gives to you, you're expected to pay it back to not be immoral and to pay back more to be virtuous, but you can't because you don't have that money, so in kind there are quite some people in dire situations that reject help because their moral compass tells them that they can't pay it back. Only those at rock bottom have no choice but to accept the donation and that's immoral and they don't see themselves as such. And even at "rock bottom" you have people with that attitude.
So if something like that is your societal morality, then charity is essentially a transaction "money vs dignity and self-respect", by showing how generous you are you're also exposing how "selfish" this poor person is for taking it, for being dependent on your charity.
So finding ways to redistribute money subtly and without making a fuzz about it, like paying people fair wages, paying your taxes and treating entitlements as rights rather than charitable donations can make a huge difference to the individuals self-respect and dignity, showing people that they are part of society rather than an endangered species that is seen as external matters a lot.
So yeah talking about charity might actually be immoral if you end up buying prestige at the price of utterly annihilating another person's dignity.
That being said that's just one interpretation; as I've mentioned in the beginning there are lots of other motivations for charity and even if you end up doing that, it doesn't need to have been your motivation or goal. Also in some situations help is more important than pride, but as said it's not even uncommon to reject much-needed help.