Add pagination to gallery