Ok, I interpret grid as a grid ( link ). In that case, I'll assume that you want the cells in your grid to have a certain width and a certain height.
To achieve this you can use a flexbox to mount the grid.
Images can be adjusted with CSS (taking advantage of the fact that width: auto and height: auto guarantee to maintain the proportion of the image).
I have prepared a JsFiddle: link
Note: I recommend that you limit the maximum size of the images. If you do not do it, the loading time of your page will increase considerably. Another option is to reduce its size on the server.