fix gallery item template logic again