masonry for wordpress gallery

remove default styles

galleryadd_filter( 'use_default_gallery_style', '__return_false' );masonry for wordpress gallery

css for basic masonry grid

.masonry-grid{margin:auto; column-count:3;column-gap:0;}
.masonry-grid img{max-width:100%;height:auto;border:none !important; padding: 1rem;}
.masonry-grid-item{margin:0;display:inline-block;width:100%;width:100%;margin-top:0;}

note column count