-
Notifications
You must be signed in to change notification settings - Fork 0
/
photos.html
37 lines (29 loc) · 1.06 KB
/
photos.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
layout: default
---
<section class="main-content center">
<div id="imagesfeed" class="main-logo">
<img id="loader" src="{{ site.media_server }}/images/ajax-loader.gif" />
</div>
</article>
<script>
var url = "http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=7b579bda632e39cb538cd2a0f1545023&user_id=60671792%40N02&tags=me&format=json&nojsoncallback=1";
$.getJSON(url + "&format=json&jsoncallback=?", function(data){
var dataLen = data.photos.photo.length;
var randomPhoto = Math.floor(Math.random() * data.photos.photo.length);
var item = data.photos.photo[randomPhoto];
$.each(data.photos.photo, function(i,item){
console.log("item.id" + item.id)
src = "http://farm"+ item.farm +".static.flickr.com/"+ item.
server +"/"+ item.id +"_"+ item.secret +"_m_d.jpg";
$("<img/>").attr("src", src).appendTo("#imagesfeed");
});
})
.complete(function() {
$('#loader').hide();
})
.error(function() {
$("<img/>").attr("src", "http://erickguevara.me/images/default.jpg").appendTo("#imagesfeed");
})
;
</script>