Combine each function into one column


#1

Hello

When selecting images it always get the first result, so to get all of the image im using this

$('#lightbox li img').each(function(){
        imgs.push(url + $(this).attr('src'));
    });

this returns the results in multiple columns, what i want is to return all of the images in one column


#2

Hello @AmrAli,
Thanks a lot for posting to Apify Forum in the first place.
For your question, if you don’t want to store the images in multiple columns as you have now, you need to concat the items from the array where you are storing the images now.
How you do it now, is that you push every image url to the array and the result contains this:

["https://image.com/1","https://image.com/2","https://image.com/3"] 

etc. so in the CSV result it will be multiple columns, the goal what you would like to reach is to have one column with all image urls which you can do this way:

var result = {}
var imgs = []
$('#lightbox li img').each(function(){
        imgs.push(url + $(this).attr('src'));
    });
result.imgs = imgs.length !== 0 ? imgs.join(", ") : null;

With this you will have all images like one string so it will be in one column.

console.log(result.imgs) //=>"https://image.com/1, https://image.com/2, https://image.com/3" 

If you would have any kind of question, let me know.

Best,
Vaclav