Hope you’re having a great day in the world of Webflow.
Well, let me get to the point.
I’m trying to get the image from the next item in a collection. I’m already using this code to get the URL from the next item, but i have no idea how get a image as well:
<script>
var Webflow = Webflow || [];
Webflow.push(function () {
var next_href = $('#post_list .w--current').parent().next().find('a').attr('href');
var previous_href = $('#post_list .w--current').parent().prev().find('a').attr('href');
//if last post in list
if(next_href == undefined) {
next_href = $('#post_list').children().children().first().find('a').attr('href');
}
//if first post in list
if(previous_href == undefined) {
previous_href = $('#post_list').children().children().last().find('a').attr('href');
}
//apply hrefs to next / previous buttons
$('#next_button').attr('href', next_href);
$('#previous_button').attr('href', previous_href);
});
</script>
I made this amazing illustration of what it want (don’t be jealous of my drawing skills):
You will find what you are looking for on the “Works Template” collection page, then scroll to the bottom.
So again, i want to show the next “Thumbnail Image” of the next collection item, under the “Next” text. But i want to see if there is a way to do this with custom code.