Implemenation of a function to create a responsive grid image layout