-
-
Save subfighter3/36bec9ccec1da90f597a832a2a017e5b to your computer and use it in GitHub Desktop.
Per Pyetro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (have_posts()): ?> | |
<ul id="image-data-list"> | |
<?php while(have_posts()): the_post(); ?> | |
<li data-image-url="<?= your_post_image_url ?>"></li> | |
<?php endwhile; ?> | |
</ul> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener( 'DOMContentLoaded', function( event ) { | |
const imagesData = document.querySelectorAll('#image-data-list > li'); | |
const imagesUrlList = []; | |
[...imagesData].forEach(image => { | |
const url = image.getAttribute("data-image-url"); | |
if (url) { | |
imagesUrlList.push(url); | |
} | |
}); | |
imagesUrlList.each(imageUrl => { | |
// load the imageUrl | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var imagesUrlList = []; | |
$("#image-list > li").each(function() { | |
var url = $(this).data("image-url"); | |
if (url !== "" && url !== null) { | |
imagesUrlList.push(url); | |
} | |
}); | |
imagesUrlList.each(imageUrl => { | |
// load the imageUrl | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment