Fix 500 error with gallery.