How to get all images from cloudinary and display them in my web page ?
I have a node.js website that serve 2 html pages:
-First page to upload images using the upload widget. (this works great )
-Second page where i wanna display all images from a folder called "LostDocs"(which ofc exist in the media library).
How can i dynamically display all the images in the second page from "LostDocs" ?
Note: I can Display single images by pasting their URL inside the img tag, but i can't rely on this since the website will have thousands of images later on.
thank you in advance
-
Hi,
You should be able to do this by using the Search API to list all the images URL in your `LostDocs` folder and then display it on your second page. Here is a script that will list all the URLs and put them in an array:
var result = [];
var options = { resource_type:"image", folder:"your_folder", max_results: 500};
function listResources(next_cursor) {
if(next_cursor) {
options["next_cursor"] = next_cursor;
}
console.log(options);
cloudinary.api.resources(options, function(error,res){
if (error) {
console.log(error);
}
var more = res.next_cursor;
resources = res.resources;
for(var res in resources) {
res = resources[res];
var resultTemp = [];
var url = res.secure_url;
resultTemp.push(url);
result.push(resultTemp);
}
if (more) {listResources(more);}
else {console.log("done");}
});
}
listResources(null);Best,
Loic
Post is closed for comments.
Comments
3 comments