gallery button logic