spences10
12/31/2016 - 4:14 PM

Random image from flickr

Random image from flickr

$(document).ready(function () {
    var keyword = $("#main").text + ', weather, landscape';
    $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", {
            tags: keyword,
            tagmode: "any",
            format: "json"
        },
        function (data) {
            var rnd = Math.floor(Math.random() * data.items.length);
            var image_src = data.items[rnd]['media']['m'].replace("_m", "_b");
            $('body').css('background-image', "url('" + image_src + "')");
            $('body').css({
                "background-size": "cover",
                "background-attachment": "fixed",
                "background-repeat": "no-repeat"
            });
        });
});