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); }