new gallery logic: fixed "show from side" bug with indexes