by the way thought I would share my test on my test site
Main Index - PhotoPost Classifieds
I am running the default 4.21 code set a static avatar as you can see for the accessories category and uploaded to it the avatar did not change which is why I have no idea how yours would since that if clause is very specific.