I'd like to create an array (or something, I'm not sure if I'm right) that will hold various tags, and then the script will chose some of them (not only one of them) and post images from that tag. So far with help of fellow programmers I managed to create a simple script that grabs images from one tag, and I'd like to expand on that. Here's the full code:
<script>
$(document).ready(function (){
var link = "http://api.tumblr.com/v2/tagged?tag=vhs";
$.ajax({
type: "GET",
url : link,
dataType: "jsonp",
data: {
api_key: "PgAKpKfv1Tcjo1uhsKEuriThhwH9XDJonRobaGwckw8RJt2tos"
}
}).done(function( data ) {
$.each(data.response, function(){
var _photos = this.photos;
$.each(_photos, function(){
$('body').append("<img src='" + this.original_size.url + "'/>");
});
});
});
});
</script>
According to a comment there is no way to grab images from more than one tag at once. How to modify the existing one to grab a random one from an array?
Just have an array of tags, then iterate it to call and retrieve items from each and one of them.
i.e.:
tags = ['george', 'of', 'the', 'jungle'];
iterateTags(tags);
function iterateTags(tags)
{
for (var i = 0; i < tags.length; i++) {
tag = tags[i];
endURL = tagsURL + tag;
callTumblr(endURL);
}
}
Demo at http://jsfiddle.net/4awvc3m6/6/