Fixed paths for middleware
Issue #8599 by tuj: Fixed media selection