Refactored photo ajax controller