yah, you could run a query.. but there is an issue..
what if a user belongs to multiple groups (very common) and those groups all have images?
which one wins ?
that's why, when i did this as a mod, i added a 'display priority' to sort things out for overlaps..