I have a gallery of images and I would like to display them in a polaroid card-based system spanning multiple rows and columns. The problem I'm facing relates to the layout of the image. When images are both portrait and landscape, the mat-card attribute for the landscape ones gets bloated up to match the size of the portrait ones. How can I have a naturally filling system where the mat-card is adaptable to the width/height ratio of the image?
HTML:
<div fxLayout="row">
<div layout="column">
<div fxFlex="100" fxFlexOffset="1" fxLayoutWrap fxLayoutGap="2rem" class="mat-elevation-z0" *ngIf="postcards != null">
<mat-card *ngFor="let postcard of postcards let index = index" >
<img mat-card-image src="{{postcard.img}}" alt="{{postcard.postcard_id}}" class="postcards" (click)="display_postcard(index)">
</mat-card>
</div>
</div>
</div>
CSS:
.postcards {
max-width: 320px;
}
And this is what I would like to achieve:

Thank you!
