Edit snippet "Masonry Grid Auto-Rows" ‹ currentMood — WordPress

PHOTO EMBED

Mon Mar 27 2023 06:55:53 GMT+0000 (Coordinated Universal Time)

Saved by @vishalbhan #undefined

function resizeGridItem(item){

  grid = document.getElementsByClassName("layout-classic")[0];

  rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));

  rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));

    imgHeight = item.querySelector('.featured-img').getBoundingClientRect().height

    contentHeight = item.querySelector('.post-content').getBoundingClientRect().height

  rowSpan = Math.ceil(((imgHeight+contentHeight)+rowGap)/(rowHeight+rowGap));

    item.style.gridRowEnd = "span "+rowSpan;

}

​

function resizeAllGridItems(){

  allItems = document.querySelectorAll(".layout-classic .post");

  for(x=0;x<allItems.length;x++){

    resizeGridItem(allItems[x]);

  }

}

​

function resizeInstance(instance){

    item = instance.elements[0];

  resizeGridItem(item);

}
content_copyCOPY

https://www.currentmoodmag.com/wp-admin/admin.php?page