[ticket/12457] Default to first category if none is selected in gallery avatar

If any category exists, the key() function should always return the first
key of the $avatar_list array.

Ticket: https://tracker.phpbb.com/browse/PHPBB3-12457

PHPBB3-12457