r addImgLayout = function () { var img = document.querySelectorAll('.post-content img'); var i; for (i = 0; i < img.length; i++) { var wrapper = document.createElement('a'); wrapper.setAttribute('data-fslightbox', 'gallery'); wrapper.setAttribute('href', img[i].getAttribute('data-src')); wrapper.setAttribute('style', 'width: 100%; display: flex; justify-content: center;'); img[i].parentElement.insertBefore(wrapper, img[i]); wrapper.appendChild(img[i]); } refreshFsLightbox(); }