Set images max height
Refactor js